To make a
List
of integers in Java, do this: List.of(1, 2, 3)
.Here's how you do it:
var list1 = java.util.List.of(1, 2, 3);
var list2 = java.util.List.of(100, 51, 77, -2);
System.out.println(list1); // [1, 2, 3]
System.out.println(list2); // [100, 51, 77, -2]