Java循环小技巧

觉得python中循环很灵活,比如遍历自定义的一个列表:

for x in (1,2,3,5):
    print(x)

其实Java也可以写出很短小干净的等效代码:

for (int x : Arrays.asList(1, 2, 3, 5)) {
    System.out.println(x);
}
原文地址:https://www.cnblogs.com/fstang/p/3099763.html