public static void main(string args[]) {
int t=0;
while(1) {
if(t++<10)
break;
}
}
What will be the value of ‘t’ after the while loop? D
A. 11
B. 9
C. 10
D. Compilation error
E. An Exception will occur.请问答案是D还是E,这两者的区别是?
int t=0;
while(1) {
if(t++<10)
break;
}
}
What will be the value of ‘t’ after the while loop? D
A. 11
B. 9
C. 10
D. Compilation error
E. An Exception will occur.请问答案是D还是E,这两者的区别是?
while() 需要的参数是boolean型的,而此处给的是int
比如你定义数组int[] a;没有初始化就在下面的程序带噢用a[0],那么就无法编译。如果你初始化了a[] ,但是你在调用的时候使用a[i]读取数组,可是i的值为负值,就会出现Exception 。