Skip to content

Instantly share code, notes, and snippets.

@thospfuller
Created April 18, 2024 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thospfuller/0145747fdb85da1aa646007284eb8aae to your computer and use it in GitHub Desktop.
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!"
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;
@thospfuller
Copy link
Author

thospfuller commented Apr 18, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment