In some languages, Python, for example, one could directly iterate through an array:
for i in [1, 2, 3, 4]: print(i) I know Java can iterate through a variable by for (type var : var2), then is it possible to skip the variable and directly iterate an array? such as:
for (int i : [1, 2, 3, 4]) { System.out.println(i); }
[1, 2, 3, 4]supposed to be? There are no list literals in Java.for (int i : new int[] {1, 2, 3, 4})[1, 2, 3, 4]just as a demo.