Created
April 18, 2024 20:14
-
-
Save thospfuller/0145747fdb85da1aa646007284eb8aae to your computer and use it in GitHub Desktop.
Example code for the article entitled "Tutorial: Learn how to use the java.util.Arrays asList method in Java now!"
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
import static java.util.Arrays.asList | |
import java.util.List | |
import java.util.Random | |
Random random = new Random() | |
int arrayCapacity = 10000 | |
def numbers = new java.lang.Integer[arrayCapacity + 1] | |
for (int ctr in 0..arrayCapacity) | |
numbers[ctr] = java.lang.Integer.valueOf (random.nextInt()) | |
List<Integer> result = asList (numbers) | |
println "result.class: ${result.class}, size: ${result.size ()}, first five values: " | |
for (int ctr in 0..5) | |
println "\t* ${result.get(ctr)}" | |
return; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See also: