Skip to content

Commit eccbfec

Browse files
authored
Merge pull request #146 from javaevolved/copilot/fix-stream-toarray-typing
Fix stream-toarray-typed: align metadata with filter+copy pattern in both approaches
2 parents 07682d5 + f106918 commit eccbfec

File tree

13 files changed

+19
-18
lines changed

13 files changed

+19
-18
lines changed

content/collections/stream-toarray-typed.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ difficulty: "beginner"
77
jdkVersion: "8"
88
oldLabel: "Pre-Streams"
99
modernLabel: "Java 8+"
10-
oldApproach: "Manual Array Copy"
10+
oldApproach: "Manual Filter + Copy"
1111
modernApproach: "toArray(generator)"
1212
oldCode: |-
1313
List<String> list = getNames();
@@ -22,10 +22,11 @@ modernCode: |-
2222
String[] arr = getNames().stream()
2323
.filter(n -> n.length() > 3)
2424
.toArray(String[]::new);
25-
summary: "Convert streams to typed arrays with a method reference."
26-
explanation: "The toArray(IntFunction) method creates a properly typed array from\
27-
\ a stream. The generator (String[]::new) tells the stream what type of array to\
28-
\ create."
25+
summary: "Filter a collection and collect the results to a typed array using a single stream expression."
26+
explanation: "When you need to filter a collection before converting it to a typed array,\
27+
\ streams let you chain the operations without an intermediate list. The toArray(IntFunction)\
28+
\ generator (String[]::new) creates the correctly typed array directly at the end\
29+
\ of the pipeline, eliminating the manual loop and temporary ArrayList."
2930
whyModernWins:
3031
- icon: "🎯"
3132
title: "Type-safe"
@@ -35,7 +36,7 @@ whyModernWins:
3536
desc: "Works at the end of any stream pipeline."
3637
- icon: "📏"
3738
title: "Concise"
38-
desc: "One expression replaces the manual loop."
39+
desc: "No intermediate list — one expression replaces the manual loop and copy."
3940
support:
4041
state: "available"
4142
description: "Widely available since JDK 8 (March 2014)"

translations/content/ar/collections/stream-toarray-typed.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
title: "تحويل Stream إلى مصفوفة محدّدة النوع"
2-
oldApproach: "نسخ المصفوفة يدوياً"
2+
oldApproach: "تصفية يدوية + نسخ"
33
modernApproach: "toArray(generator)"
44
summary: "حوّل Stream إلى مصفوفة محدّدة النوع باستخدام مرجع دالة."
55
explanation: "تُنشئ الدالة toArray(IntFunction) مصفوفةً محدّدة النوع من Stream. يُخبر المولّد (String[]::new) التدفقَ بنوع المصفوفة المراد إنشاؤها."

translations/content/bn/collections/stream-toarray-typed.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: টাইপড স্ট্রিমকে অ্যারেতে রূপান্তর (Typed Stream toArray)
3-
oldApproach: ম্যানুয়াল অ্যারে কপি
3+
oldApproach: ম্যানুয়াল ফিল্টার + কপি
44
modernApproach: toArray(generator)
55
summary: একটি মেথড রেফারেন্স (method reference) ব্যবহার করে স্ট্রিমকে টাইপড অ্যারেতে রূপান্তর করুন।
66
explanation: toArray(IntFunction) মেথডটি একটি স্ট্রিম থেকে সঠিক টাইপের অ্যারে তৈরি করে। এখানে জেনারেটর (যেমন String[]::new) স্ট্রিমকে বলে দেয় কোন ধরনের অ্যারে তৈরি করতে হবে।

translations/content/de/collections/stream-toarray-typed.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
title: Typisiertes Stream-toArray
2-
oldApproach: Manuelle Array-Kopie
2+
oldApproach: Manuelle Filterung + Kopie
33
modernApproach: "toArray(generator)"
44
summary: Streams mit einer Methodenreferenz in typisierte Arrays umwandeln.
55
explanation: "Die Methode toArray(IntFunction) erstellt ein korrekt typisiertes Array\

translations/content/es/collections/stream-toarray-typed.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "toArray tipado en streams"
3-
oldApproach: "Copia manual de array"
3+
oldApproach: "Filtro manual + copia"
44
modernApproach: "toArray(generator)"
55
summary: "Convierte streams en arrays tipados con una referencia a método."
66
explanation: "El método toArray(IntFunction) crea un array correctamente tipado a\

translations/content/fr/collections/stream-toarray-typed.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "toArray typé dans les streams"
3-
oldApproach: "Copie manuelle de tableau"
3+
oldApproach: "Filtrage manuel + copie"
44
modernApproach: "toArray(generator)"
55
summary: "Convertit des streams en tableaux typés avec une référence de méthode."
66
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."

translations/content/it/collections/stream-toarray-typed.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Stream toArray tipizzato
3-
oldApproach: Copia manuale dell'array
3+
oldApproach: Filtraggio manuale + copia
44
modernApproach: toArray(generatore)
55
summary: "Converti gli stream in array tipizzati con un riferimento a metodo."
66
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."

translations/content/ja/collections/stream-toarray-typed.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
title: 型付きストリームのtoArray
2-
oldApproach: 手動配列コピー
2+
oldApproach: 手動フィルタリング + コピー
33
modernApproach: toArray(ジェネレータ)
44
summary: "メソッド参照を使ってストリームを型付き配列に変換する。"
55
explanation: "toArray(IntFunction)メソッドはストリームから適切に型付けされた配列を作成します。ジェネレータ(String[]::new)は、ストリームが作成する配列の型を指定します。"

translations/content/ko/collections/stream-toarray-typed.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
title: "타입이 지정된 스트림 toArray"
2-
oldApproach: "수동 배열 복사"
2+
oldApproach: "수동 필터 + 복사"
33
modernApproach: "toArray(생성자)"
44
summary: "메서드 참조로 스트림을 타입이 지정된 배열로 변환합니다."
55
explanation: "toArray(IntFunction) 메서드는 스트림에서 올바르게 타입이 지정된 배열을 만듭니다. 생성자(String[]::new)는 스트림에 생성할 배열 타입을 알려줍니다."

translations/content/pl/collections/stream-toarray-typed.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
title: Typowana konwersja strumienia do tablicy
2-
oldApproach: Ręczne kopiowanie tablicy
2+
oldApproach: Ręczne filtrowanie + kopiowanie
33
modernApproach: toArray(generator)
44
summary: Konwertuj strumienie do typowanych tablic za pomocą referencji do metody.
55
explanation: Metoda toArray(IntFunction) tworzy poprawnie typowaną tablicę ze strumienia. Generator (String[]::new) mówi strumieniowi, jakiego typu tablicę utworzyć.

0 commit comments

Comments
 (0)