我想,一旦我的異常引發它打破了我的循環(使用斷點功能)&打印我(長數組)計算數組的長度,而無需使用length屬性
class Length{
static void length(String p){
int i=0;
try{
while(i<=i){
char ch=p.charAt(i);
i++;
System.out.println(ch);
}
}
catch(Exception e){
System.out.println(e);
}
}
public static void main(String s[]){
String a=new String("jack");
length(a);
}
}
從你的'try'塊拋出的異常會阻止進一步的迭代長度'而'循環。 – 2014-09-29 04:17:56