We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 80b7dcd commit 50e629eCopy full SHA for 50e629e
collections/arraylist/convert-arraylist-to-array/ArrayListToArray2.java
@@ -28,7 +28,10 @@ public static void main(String[] args) {
28
29
// convert ArrayList to array
30
// pass a new String array of the arrayList size as a param to toArray
31
- String[] elements = arrayList.toArray(new String[arrayList.size()]);
+ //String[] elements = arrayList.toArray(new String[arrayList.size()]);
32
+
33
+ //kindly read the 'Important Note' below
34
+ String[] elements = arrayList.toArray(new String[0]);
35
36
System.out.println("\nArray:");
37
//we will receive the string array, so iterate on it to print each element
0 commit comments