CS61B HW0

The Enhanced For Loop

public class EnhancedForBreakDemo {
public static void main(String[] args) {
String[] a = {"cat", "dog", "laser horse", "ketchup", "horse", "horbse"}; for (String s : a) {
for (int j = 0; j < 3; j += 1) {
System.out.println(s);
if (s.contains("horse")) {
break;
}
}
}
}
}

here "String s : a" is equal to for i loop and use s to replace a[i]

上一篇:ADO.Net(四)——扩展属性和配置文件应用


下一篇:张小龙2018PRO版微信公开课演讲全文 透露2018微信全新计划