大家讲道理2017-04-18 10:40:16
The object traversed must be object, not a basic type. Array types are not classes, but array instances are objects. But in this case, your array has not yet become an instance, so an error is reported.
黄舟2017-04-18 10:40:16
The second syntax is incorrect. There is no such way of writing in Java
.
for (int a:new int[] {3,4}) {
System.out.println(a);
}