Last active
March 9, 2023 11:09
-
-
Save adojos/fa7b6c9b11145d30092251747153cc96 to your computer and use it in GitHub Desktop.
Java: Convert List to Array : Using Stream without 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 convertUsingStream() { | |
List<Integer> inputList = Arrays.asList(2, 4, 6, 8, 10); | |
Stream<Integer> inputStream = inputList.stream(); | |
Object[] objArray = inputStream.toArray(); | |
//print the elements in the array | |
for (Object num : objArray) { | |
System.out.print(num + " "); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment