From c2e101901a447e22b6573a77e3cc2d9d7ea0e089 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Mar 2026 17:21:02 +0000 Subject: [PATCH 1/2] Initial plan From f1069180aef2898d9380d4ab0e4be18e4c0b5e60 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Mar 2026 17:28:32 +0000 Subject: [PATCH 2/2] Fix stream-toarray-typed: update labels and descriptions to reflect filter+copy in both approaches Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com> Agent-Logs-Url: https://github.com/javaevolved/javaevolved.github.io/sessions/9eef2156-f7cf-4dac-8bb3-a3fb4be7c5e5 --- content/collections/stream-toarray-typed.yaml | 13 +++++++------ .../ar/collections/stream-toarray-typed.yaml | 2 +- .../bn/collections/stream-toarray-typed.yaml | 2 +- .../de/collections/stream-toarray-typed.yaml | 2 +- .../es/collections/stream-toarray-typed.yaml | 2 +- .../fr/collections/stream-toarray-typed.yaml | 2 +- .../it/collections/stream-toarray-typed.yaml | 2 +- .../ja/collections/stream-toarray-typed.yaml | 2 +- .../ko/collections/stream-toarray-typed.yaml | 2 +- .../pl/collections/stream-toarray-typed.yaml | 2 +- .../pt-BR/collections/stream-toarray-typed.yaml | 2 +- .../tr/collections/stream-toarray-typed.yaml | 2 +- .../zh-CN/collections/stream-toarray-typed.yaml | 2 +- 13 files changed, 19 insertions(+), 18 deletions(-) diff --git a/content/collections/stream-toarray-typed.yaml b/content/collections/stream-toarray-typed.yaml index da3bca5..7fb7897 100644 --- a/content/collections/stream-toarray-typed.yaml +++ b/content/collections/stream-toarray-typed.yaml @@ -7,7 +7,7 @@ difficulty: "beginner" jdkVersion: "8" oldLabel: "Pre-Streams" modernLabel: "Java 8+" -oldApproach: "Manual Array Copy" +oldApproach: "Manual Filter + Copy" modernApproach: "toArray(generator)" oldCode: |- List list = getNames(); @@ -22,10 +22,11 @@ modernCode: |- String[] arr = getNames().stream() .filter(n -> n.length() > 3) .toArray(String[]::new); -summary: "Convert streams to typed arrays with a method reference." -explanation: "The toArray(IntFunction) method creates a properly typed array from\ - \ a stream. The generator (String[]::new) tells the stream what type of array to\ - \ create." +summary: "Filter a collection and collect the results to a typed array using a single stream expression." +explanation: "When you need to filter a collection before converting it to a typed array,\ + \ streams let you chain the operations without an intermediate list. The toArray(IntFunction)\ + \ generator (String[]::new) creates the correctly typed array directly at the end\ + \ of the pipeline, eliminating the manual loop and temporary ArrayList." whyModernWins: - icon: "🎯" title: "Type-safe" @@ -35,7 +36,7 @@ whyModernWins: desc: "Works at the end of any stream pipeline." - icon: "📏" title: "Concise" - desc: "One expression replaces the manual loop." + desc: "No intermediate list — one expression replaces the manual loop and copy." support: state: "available" description: "Widely available since JDK 8 (March 2014)" diff --git a/translations/content/ar/collections/stream-toarray-typed.yaml b/translations/content/ar/collections/stream-toarray-typed.yaml index 73abc19..6bf32c8 100644 --- a/translations/content/ar/collections/stream-toarray-typed.yaml +++ b/translations/content/ar/collections/stream-toarray-typed.yaml @@ -1,5 +1,5 @@ title: "تحويل Stream إلى مصفوفة محدّدة النوع" -oldApproach: "نسخ المصفوفة يدوياً" +oldApproach: "تصفية يدوية + نسخ" modernApproach: "toArray(generator)" summary: "حوّل Stream إلى مصفوفة محدّدة النوع باستخدام مرجع دالة." explanation: "تُنشئ الدالة toArray(IntFunction) مصفوفةً محدّدة النوع من Stream. يُخبر المولّد (String[]::new) التدفقَ بنوع المصفوفة المراد إنشاؤها." diff --git a/translations/content/bn/collections/stream-toarray-typed.yaml b/translations/content/bn/collections/stream-toarray-typed.yaml index 86a2cc3..c55d5b0 100644 --- a/translations/content/bn/collections/stream-toarray-typed.yaml +++ b/translations/content/bn/collections/stream-toarray-typed.yaml @@ -1,6 +1,6 @@ --- title: টাইপড স্ট্রিমকে অ্যারেতে রূপান্তর (Typed Stream toArray) -oldApproach: ম্যানুয়াল অ্যারে কপি +oldApproach: ম্যানুয়াল ফিল্টার + কপি modernApproach: toArray(generator) summary: একটি মেথড রেফারেন্স (method reference) ব্যবহার করে স্ট্রিমকে টাইপড অ্যারেতে রূপান্তর করুন। explanation: toArray(IntFunction) মেথডটি একটি স্ট্রিম থেকে সঠিক টাইপের অ্যারে তৈরি করে। এখানে জেনারেটর (যেমন String[]::new) স্ট্রিমকে বলে দেয় কোন ধরনের অ্যারে তৈরি করতে হবে। diff --git a/translations/content/de/collections/stream-toarray-typed.yaml b/translations/content/de/collections/stream-toarray-typed.yaml index a0a0bc8..e4c2f46 100644 --- a/translations/content/de/collections/stream-toarray-typed.yaml +++ b/translations/content/de/collections/stream-toarray-typed.yaml @@ -1,5 +1,5 @@ title: Typisiertes Stream-toArray -oldApproach: Manuelle Array-Kopie +oldApproach: Manuelle Filterung + Kopie modernApproach: "toArray(generator)" summary: Streams mit einer Methodenreferenz in typisierte Arrays umwandeln. explanation: "Die Methode toArray(IntFunction) erstellt ein korrekt typisiertes Array\ diff --git a/translations/content/es/collections/stream-toarray-typed.yaml b/translations/content/es/collections/stream-toarray-typed.yaml index 086834a..5fa1312 100644 --- a/translations/content/es/collections/stream-toarray-typed.yaml +++ b/translations/content/es/collections/stream-toarray-typed.yaml @@ -1,6 +1,6 @@ --- title: "toArray tipado en streams" -oldApproach: "Copia manual de array" +oldApproach: "Filtro manual + copia" modernApproach: "toArray(generator)" summary: "Convierte streams en arrays tipados con una referencia a método." explanation: "El método toArray(IntFunction) crea un array correctamente tipado a\ diff --git a/translations/content/fr/collections/stream-toarray-typed.yaml b/translations/content/fr/collections/stream-toarray-typed.yaml index 4340844..58e1c3c 100644 --- a/translations/content/fr/collections/stream-toarray-typed.yaml +++ b/translations/content/fr/collections/stream-toarray-typed.yaml @@ -1,6 +1,6 @@ --- title: "toArray typé dans les streams" -oldApproach: "Copie manuelle de tableau" +oldApproach: "Filtrage manuel + copie" modernApproach: "toArray(generator)" summary: "Convertit des streams en tableaux typés avec une référence de méthode." explanation: "La méthode toArray(IntFunction) crée un tableau correctement typé à partir d'un stream. Le générateur (String[]::new) indique au stream quel type de tableau créer." diff --git a/translations/content/it/collections/stream-toarray-typed.yaml b/translations/content/it/collections/stream-toarray-typed.yaml index cdbff94..0376b75 100644 --- a/translations/content/it/collections/stream-toarray-typed.yaml +++ b/translations/content/it/collections/stream-toarray-typed.yaml @@ -1,6 +1,6 @@ --- title: Stream toArray tipizzato -oldApproach: Copia manuale dell'array +oldApproach: Filtraggio manuale + copia modernApproach: toArray(generatore) summary: "Converti gli stream in array tipizzati con un riferimento a metodo." explanation: "Il metodo toArray(IntFunction) crea un array correttamente tipizzato da uno stream. Il generatore (String[]::new) indica allo stream quale tipo di array creare." diff --git a/translations/content/ja/collections/stream-toarray-typed.yaml b/translations/content/ja/collections/stream-toarray-typed.yaml index b59b8b7..27b19bd 100644 --- a/translations/content/ja/collections/stream-toarray-typed.yaml +++ b/translations/content/ja/collections/stream-toarray-typed.yaml @@ -1,5 +1,5 @@ title: 型付きストリームのtoArray -oldApproach: 手動配列コピー +oldApproach: 手動フィルタリング + コピー modernApproach: toArray(ジェネレータ) summary: "メソッド参照を使ってストリームを型付き配列に変換する。" explanation: "toArray(IntFunction)メソッドはストリームから適切に型付けされた配列を作成します。ジェネレータ(String[]::new)は、ストリームが作成する配列の型を指定します。" diff --git a/translations/content/ko/collections/stream-toarray-typed.yaml b/translations/content/ko/collections/stream-toarray-typed.yaml index bd5db27..4c714d6 100644 --- a/translations/content/ko/collections/stream-toarray-typed.yaml +++ b/translations/content/ko/collections/stream-toarray-typed.yaml @@ -1,5 +1,5 @@ title: "타입이 지정된 스트림 toArray" -oldApproach: "수동 배열 복사" +oldApproach: "수동 필터 + 복사" modernApproach: "toArray(생성자)" summary: "메서드 참조로 스트림을 타입이 지정된 배열로 변환합니다." explanation: "toArray(IntFunction) 메서드는 스트림에서 올바르게 타입이 지정된 배열을 만듭니다. 생성자(String[]::new)는 스트림에 생성할 배열 타입을 알려줍니다." diff --git a/translations/content/pl/collections/stream-toarray-typed.yaml b/translations/content/pl/collections/stream-toarray-typed.yaml index 6361733..0a3e627 100644 --- a/translations/content/pl/collections/stream-toarray-typed.yaml +++ b/translations/content/pl/collections/stream-toarray-typed.yaml @@ -1,5 +1,5 @@ title: Typowana konwersja strumienia do tablicy -oldApproach: Ręczne kopiowanie tablicy +oldApproach: Ręczne filtrowanie + kopiowanie modernApproach: toArray(generator) summary: Konwertuj strumienie do typowanych tablic za pomocą referencji do metody. explanation: Metoda toArray(IntFunction) tworzy poprawnie typowaną tablicę ze strumienia. Generator (String[]::new) mówi strumieniowi, jakiego typu tablicę utworzyć. diff --git a/translations/content/pt-BR/collections/stream-toarray-typed.yaml b/translations/content/pt-BR/collections/stream-toarray-typed.yaml index fb6d5a9..0b9212f 100644 --- a/translations/content/pt-BR/collections/stream-toarray-typed.yaml +++ b/translations/content/pt-BR/collections/stream-toarray-typed.yaml @@ -1,5 +1,5 @@ title: toArray tipado com streams -oldApproach: Cópia manual de array +oldApproach: Filtro manual + cópia modernApproach: toArray(generator) summary: Converta streams em arrays tipados com uma referência de método. explanation: "O método toArray(IntFunction) cria um array com tipo correto a partir\ diff --git a/translations/content/tr/collections/stream-toarray-typed.yaml b/translations/content/tr/collections/stream-toarray-typed.yaml index 6486725..1c11267 100644 --- a/translations/content/tr/collections/stream-toarray-typed.yaml +++ b/translations/content/tr/collections/stream-toarray-typed.yaml @@ -1,6 +1,6 @@ --- title: Tiplendirilmiş stream toArray -oldApproach: Elle Dizi Kopyalama +oldApproach: Elle Filtreleme + Kopyalama modernApproach: toArray(generator) summary: "Stream'leri metot referansıyla tiplendirilmiş dizilere dönüştürün." explanation: "toArray(IntFunction) metodu, bir stream'den düzgün tiplendirilmiş bir dizi oluşturur. Üretici (String[]::new), stream'e hangi türde dizi oluşturacağını söyler." diff --git a/translations/content/zh-CN/collections/stream-toarray-typed.yaml b/translations/content/zh-CN/collections/stream-toarray-typed.yaml index 66471fe..dab29dd 100644 --- a/translations/content/zh-CN/collections/stream-toarray-typed.yaml +++ b/translations/content/zh-CN/collections/stream-toarray-typed.yaml @@ -1,6 +1,6 @@ --- title: 类型化流 toArray -oldApproach: 手动数组复制 +oldApproach: 手动过滤 + 复制 modernApproach: toArray(generator) summary: "使用方法引用将流转换为类型化数组。" explanation: "toArray(IntFunction) 方法从流创建正确类型化的数组。传递 String[]::new 获取 String[],而非 Object[]。"