现在的位置: 首页 > 综合 > 正文

scjp卡壳题

2018年05月10日 ⁄ 综合 ⁄ 共 399字 ⁄ 字号 评论关闭

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;
	}
}

抱歉!评论已关闭.