定義報錯cannot find symbol
public?class?HelloWorld?{
????
????//完成?main?方法
????public?static?void?main(String[]?args)?{
????????int?[]?scroes?={89,-23,6,91,119,52,73};
????????HelloWorld?hello=new?HelloWorld();
????????int??nums?[]=hello.garde(scroes);
????????for(int?i=0;i<3;i++)
????????System.out.println(nums[i]);
????????
????????
????????
????}
????
????//定義方法完成成績排序并輸出前三名的功能
????
????public?int?[]?garde?(int?scroes?[])
????{
???????
????????for(int?i=0;i<scroes.length-1;i++){
????????????for(int?j=i+1;j<scroes.length;j++){
????????????????if(scroes[i]<scores[j])
????????????????{
????????????????????int?temp=scroes[j];
????????????????????scroes[j]=scroes[i];
????????????????????scroes[i]=temp;
????????????????}
????????????}
????????}
????????return?scroes?;
????}說我第23行定義報錯,看了半天沒看懂這是為什么
/85/1598/Jcdd/HelloWorld.java:23: error: cannot find symbol
? ? ? ? ? ? ? ?if(scroes[i]
2016-12-31
第22行,后面的scores應該改成scroes,你前面都是定義的scroes的,改過來試試
2016-12-31
因為你22行 ? if判斷里面 ? score寫錯了