K
kmgyl
Unregistered / Unconfirmed
GUEST, unregistred user!
public class ttt {
public ttt() {
}
public static void main(String[] args)
{
int x=1;
String[] names={"this 1","this 2","this 3"};
names[-x]+=".";
for (int i=0;i<names.length;i++)
{
System.out.println(names);
}
}
}
大家说结果是什么
这是认证考试测试书上的一道题
有三个答案
1:OUTPUT IS this 1 WITH A TRAILING PERIOD
2:OUTPUT IS this 2 WITH A TRAILING PERIOD
3:OUTPUT IS this 3 WITH A TRAILING PERIOD
4:NONE
5:AN ArrayIndexOutOfBoundsException is thrown
我测试的结果是 5,但答案是1 。。。为什么?????