j**a 程序运行错误

时间:2013.07.01 发布人:thelifezp43

j**a 程序运行错误

已解决问题

谷歌thelifezp43用户在2013.07.01提交了关于“三十而已j**a 程序运行错误”的提问,欢迎大家涌跃发表自己的观点。目前共有1个回答,最后更新于2024-11-06T11:02:05。importj**a.util.*;
publicclassGame21{
publicstaticvoidmain(String[]args){
ArrayList<Integer>ZhiPai=newArrayList();
inti=1;
while(i<=53){
ZhiPai.add(i);
}
System.out.println(ZhiPai);
for(intj=1;j<50;j++){
inttemp,theRandom1,theRandom2;
theRandom1=(int)(Math.random()*53);
theRandom2=(int)(Math.random()*53);

temp=ZhiPai[theRandom1];ZhiPai[theRandom1]=ZhiPai[theRandom2];ZhiPai[theRandom2]=temp;
}

System.out.println(ZhiPai);
}
}
运行时错误:
Exceptioninthread"main"j**a.lang.Error:Unresolvedcompilationproblems:
ThetypeoftheexpressionmustbeanarraytypebutitresolvedtoArrayList<Integer>
ThetypeoftheexpressionmustbeanarraytypebutitresolvedtoArrayList<Integer>
ThetypeoftheexpressionmustbeanarraytypebutitresolvedtoArrayList<Integer>
ThetypeoftheexpressionmustbeanarraytypebutitresolvedtoArrayList<Integer>

atgame21.Game21.main(***.j**a:18)希望大家能够帮助她。

详细问题描述及疑问:importj**a.util.*;
publicclassGame21{
publicstaticvoidmain(String[]args){
ArrayList<Integer>ZhiPai=newArrayList();
inti=1;
while(i<=53){
ZhiPai.add(i);
}
System.out.println(ZhiPai);
for(intj=1;j<50;j++){
inttemp,theRandom1,theRandom2;
theRandom1=(int)(Math.random()*53);
theRandom2=(int)(Math.random()*53);

temp=ZhiPai[theRandom1];ZhiPai[theRandom1]=ZhiPai[theRandom2];ZhiPai[theRandom2]=temp;
}

System.out.println(ZhiPai);
}
}
运行时错误:
Exceptioninthread"main"j**a.lang.Error:Unresolvedcompilationproblems:
ThetypeoftheexpressionmustbeanarraytypebutitresolvedtoArrayList<Integer>
ThetypeoftheexpressionmustbeanarraytypebutitresolvedtoArrayList<Integer>
ThetypeoftheexpressionmustbeanarraytypebutitresolvedtoArrayList<Integer>
ThetypeoftheexpressionmustbeanarraytypebutitresolvedtoArrayList<Integer>

atgame21.Game21.main(***.j**a:18)期待您的答案,希望你能感受到,我最真诚的谢意 !

希望以下的回答,能够帮助你。

第1个回答

用户名:gumi0521223永帝慢6  

你里面的Z问答hipai是个ArrayList,取值要用:temp=ZhiPai.get(theRandom1);但你却按数妈着足组的方式:temp=ZhiPai[theRandom1];这是一类错误,除此之外,你的:
inti=1;
while(i<=53){
ZhiPai.add(i);
}
这段代码是死循环呀。
还有,给实例对象命名为Zhipai不标准,要用zhiPai,这样才标准。
但愿能解决你的问你问后动罪概题,不行可以追问。