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

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

一個異常問題 謝謝 如圖

import?java.util.*;
public?class?HelloWorld?{
????
????//完成?main?方法
????public?static?void?main(String[]?args)?{
????????
????????int[]?scores={89,-23,64,91,119,52,73};
????????HelloWorld?sorts=new?HelloWorld();
????????getArrays(scores);
????????
????????
????}
????
????//定義方法完成成績排序并輸出前三名的功能
????
????public?static?void?getArrays(int[]?scores){
????????Arrays.sort(scores);
????????int[]?score2=scores;
????????int[]?score3={0,0,0};
????????int?cout=0;
????????for(int?i=score2.length;i>=0;i--){
????????????if(score2[i]>100&&score2[i]<0)
????????????continue;
????????????cout+=1;
????????????score3[cout-1]=score2[i];
?????????????if(cout>3)
?????????????break;
????????????
????????}
????????System.out.println("考試成績的前三名為:\n"+
????????score3[0]+score3[1]+score3[2]);
????}


正在回答

4 回答

這是拋出ArrayIndexOutOfBoundsException異常,也就是說你的數(shù)組超出了范圍,? for(int i=score2.length-1;i>=0;i--)這里面的score2.length要減1,?if(cout>=3)這里面的cout是大于等于3。

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

慕粉3274091 提問者

非常感謝!
2016-05-01 回復(fù) 有任何疑惑可以回復(fù)我~
#2

葫蘆娃3250413 回復(fù) 慕粉3274091 提問者

不用客氣噠~樓上說的錯誤也有的昂~
2016-05-02 回復(fù) 有任何疑惑可以回復(fù)我~

第1行導(dǎo)入Arrays方法

import?java.util.Arrays;

第21行:score2[i]>100&&score<0;這個數(shù)不存在,應(yīng)該為或||

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

21行 :這個大于100 ?并且要小于0 這種數(shù)字不存在吧!你改一下試試(||)

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

舉報

0/150
提交
取消

一個異常問題 謝謝 如圖

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

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

幫助反饋 APP下載

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

公眾號

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