Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions content/collections/stream-toarray-typed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> list = getNames();
Expand All @@ -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"
Expand All @@ -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)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
title: "تحويل Stream إلى مصفوفة محدّدة النوع"
oldApproach: "نسخ المصفوفة يدوياً"
oldApproach: "تصفية يدوية + نسخ"
modernApproach: "toArray(generator)"
summary: "حوّل Stream إلى مصفوفة محدّدة النوع باستخدام مرجع دالة."
explanation: "تُنشئ الدالة toArray(IntFunction) مصفوفةً محدّدة النوع من Stream. يُخبر المولّد (String[]::new) التدفقَ بنوع المصفوفة المراد إنشاؤها."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: টাইপড স্ট্রিমকে অ্যারেতে রূপান্তর (Typed Stream toArray)
oldApproach: ম্যানুয়াল অ্যারে কপি
oldApproach: ম্যানুয়াল ফিল্টার + কপি
modernApproach: toArray(generator)
summary: একটি মেথড রেফারেন্স (method reference) ব্যবহার করে স্ট্রিমকে টাইপড অ্যারেতে রূপান্তর করুন।
explanation: toArray(IntFunction) মেথডটি একটি স্ট্রিম থেকে সঠিক টাইপের অ্যারে তৈরি করে। এখানে জেনারেটর (যেমন String[]::new) স্ট্রিমকে বলে দেয় কোন ধরনের অ্যারে তৈরি করতে হবে।
Expand Down
Original file line number Diff line number Diff line change
@@ -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\
Expand Down
Original file line number Diff line number Diff line change
@@ -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\
Expand Down
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
title: 型付きストリームのtoArray
oldApproach: 手動配列コピー
oldApproach: 手動フィルタリング + コピー
modernApproach: toArray(ジェネレータ)
summary: "メソッド参照を使ってストリームを型付き配列に変換する。"
explanation: "toArray(IntFunction)メソッドはストリームから適切に型付けされた配列を作成します。ジェネレータ(String[]::new)は、ストリームが作成する配列の型を指定します。"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
title: "타입이 지정된 스트림 toArray"
oldApproach: "수동 배열 복사"
oldApproach: "수동 필터 + 복사"
modernApproach: "toArray(생성자)"
summary: "메서드 참조로 스트림을 타입이 지정된 배열로 변환합니다."
explanation: "toArray(IntFunction) 메서드는 스트림에서 올바르게 타입이 지정된 배열을 만듭니다. 생성자(String[]::new)는 스트림에 생성할 배열 타입을 알려줍니다."
Expand Down
Original file line number Diff line number Diff line change
@@ -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ć.
Expand Down
Original file line number Diff line number Diff line change
@@ -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\
Expand Down
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: 类型化流 toArray
oldApproach: 手动数组复制
oldApproach: 手动过滤 + 复制
modernApproach: toArray(generator)
summary: "使用方法引用将流转换为类型化数组。"
explanation: "toArray(IntFunction) 方法从流创建正确类型化的数组。传递 String[]::new 获取 String[],而非 Object[]。"
Expand Down