`

scjp卡壳题

阅读更多

1.

void looper() {
		int x = 0;
		one: while (x < 10) {
		two:	 System.out.println(++x);
			if (x > 3) {
				break two;
			}
		}
}

break适用场合:<1>switch<2>for/while循环

if语句中也不能用~【注】将two换成one就可以了。

 

2.

"this" keyword can not appears in the main method, because static method can not references a member variable like "this";
 

3.这样赋值也是合法的:

Integer[] a=new Integer[5];
for(int i=0;i<5;a[i++]=i*10);

 

4.方法名和类名相同,而且也不是构造子,也是合法的,不过不推荐而已。

public class ClazzA {
	public void ClazzA(){
		return;
	}
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics