日期:2014-05-20 浏览次数:20839 次
//当break z 返回到z的时候,会不会再次开始循环? public void go(){ String o = ""; z: for(int x=0; x<3; x++){ for(int y=0; y<2; y++){ if(x == 1) break; if(x==2 && y==1) break z; o = o + x + y; } } System.out.println(o); } //5是怎么来的? public class Test { public static void main(String[] args) { String[] colors = { "blue", "red", "green", "yellow", "orange" }; Arrays.sort(colors); int s2 = Arrays.binarySearch(colors, "orange"); int s3 = Arrays.binarySearch(colors, "violet"); System.out.print(s2 + "" + s3); } } //为什么编译失败? public class Test { public static void main(String[] args) { new Test.go("hi", 1); new Test.go("hi", "world", 2); } public void go(String... y, int x) { System.out.print(y[y.length - 1] + " "); } }
public class Test { public static void main(String[] args) { new Test().go(1,"hi" ); new Test().go(2,"hi", "world" ); } public void go(int x,String... y) { System.out.print(y[y.length - 1] + " "); } }