第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

顯示25行錯(cuò)誤HelloWorld.java:25: error: cannot find symbol System.out.println(scores[i]); ^ symbol: variable i location: class HelloWorld 1 error

import?java.util.Arrays;
public?class?HelloWorld?{
????
????//完成?main?方法
????public?static?void?main(String[]?args)?{
?????????int?scores?[]?=?{89,-23,64,91,119,52,73};
?????????System.out.println("考試的前三名是:");
?????????HelloWorld?chang?=?new?HelloWorld();
???????????/*表明是一個(gè)新的類的對(duì)象*/
??????????chang.showTop3(scores);
?????}
????
????//定義方法完成成績(jī)排序并輸出前三名的功能
????public?void?showTop3?(int[]scores){
??????Arrays.sort(scores);
??????int?num=0;/*初始話最好為零,用來保存用戶數(shù)值*/
??????for(int?i?=scores.length-1;i>=0;i--??){
??????????if(scores[i]<0||scores[i]>100){
?????????????continue;?
??????????}
??????????num++;
??????????if?(num>3);
??????????break;
??????}
????System.out.println(scores[i]);
????}
}



正在回答

5 回答

你錯(cuò)誤的System.out.println(scores[i]);這行,是因?yàn)橛?jì)算機(jī)沒有抓取到Scores這個(gè)數(shù)組變量。說明你上面的數(shù)組名聲明有問題,public?void?showTop3?(int[]scores)沒有間隔

0 回復(fù) 有任何疑惑可以回復(fù)我~

變量i 是在for 語句里面定義的,作用域就在for語句里面。出了for語句,變量i 就是未定義的

0 回復(fù) 有任何疑惑可以回復(fù)我~

循環(huán)里的i不能拿出來用

2 回復(fù) 有任何疑惑可以回復(fù)我~

把輸出語句要放到循環(huán)里

0 回復(fù) 有任何疑惑可以回復(fù)我~

public?void?showTop3?(int[]scores) 改為public?void?showTop3?(int[] scores)

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

顯示25行錯(cuò)誤HelloWorld.java:25: error: cannot find symbol System.out.println(scores[i]); ^ symbol: variable i location: class HelloWorld 1 error

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)