Last active
March 9, 2023 11:09
-
-
Save adojos/e7b43a9bbacf746132a02c5c9d1a0463 to your computer and use it in GitHub Desktop.
Java: Convert List to Array : ToArray with param #java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void convertUsingToArray2() { | |
List<Integer> inputList = Arrays.asList(2, 4, 6, 8, 10); | |
Integer[] outputArray = inputList.toArray(new Integer[inputList.size()]); | |
//print the elements in the array | |
for (int num : outputArray) { | |
System.out.print(num + " "); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment