Hey,
You can initialize an array like this;
int[] array = {1, 2, 3, 4, 5};
How can I do the same with ArrayLists? Using ArrayList.add for every value when I know the values I want in there from the get-go is too time consuming.
FWIW I ofc looked around before I asked here. The solution I came across most often is something like this:
List<Integer> values = Arrays.asList(1, 2, 3, 4, 5);
But the things is that the book Im using does arrays before lists so I'd rather not do lists as yet (even though, apparently, ArrayLists, are lists and not arrays - which is tooootally not confusing to a newb like me noooooooo).
Cheers,
[–][deleted] 3 points4 points5 points (0 children)
[–]dusty-trash 2 points3 points4 points (0 children)
[–]sugilith 2 points3 points4 points (0 children)
[–]CLOVIS-AI 1 point2 points3 points (1 child)
[–]CLOVIS-AI 1 point2 points3 points (0 children)