package syntax.autoCase; import java.util.Arrays;
import java.util.List; public class autoCase { public static void main(String args[]) { List<Integer> list = Arrays.asList(1, 2, 3, 4);
//如果在JDK1.7中,还可以这样写
//List<Integer> list = {1, 2, 3, 4}; int sum = 0;
for(int i : list){
sum += i;
}
System.out.println(sum);
}
}