当前位置: 技术问答>java相关
SCJP 模拟题一道
来源: 互联网 发布时间:2015-02-13
本文导语: public class Test{ public static void manin(String sg[]){ String foo=sg[1]; String bar=sg[2]; String baz=sg[3]; } } And command line invocation: java Test red green blue What is the result? 答案:B. baz ...
public class Test{
public static void manin(String sg[]){
String foo=sg[1];
String bar=sg[2];
String baz=sg[3];
}
}
And command line invocation:
java Test red green blue
What is the result?
答案:B. baz has value of null
SG[3]已经超出了数组的界限了吧,应该出EXCEPTION?
public static void manin(String sg[]){
String foo=sg[1];
String bar=sg[2];
String baz=sg[3];
}
}
And command line invocation:
java Test red green blue
What is the result?
答案:B. baz has value of null
SG[3]已经超出了数组的界限了吧,应该出EXCEPTION?
|
对,ArrayIndexOutOfBoundsException
|
yes,sg[] from sg[0] to sg[2]
|
ArrayIndexOutOfBoundsException
|
答案错了...