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

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

哪里錯誤,請問怎么修改呢?

哪里錯誤,請問怎么修改呢?

qq_你今天真漂亮_04247659 2016-12-11 20:40:58
public class helloworld {? ??? ? //完成 main 方法? ? public static void main(String[] args) { helloworld hello = new helloworld();?? ? ? ? int maxScore=hello.getMaxAge(); // 輸出最大年齡 System.out.println("最大年齡為:" + maxScore);? }public int getMaxAge(){ ? ? ? 錯誤原因:Multiple markers at this line - This method must return a result of? type int - This method must return a result of? type int int []ages={18,23,21,19,25,29,17};? ? int max=ages[0];? ? for(int i=0;i<ages.length;i++){? ? ? ? if(ages[i]>max);? ? ? max=ages[i] ;? ? ? return max;? ? }哪里錯了呢,怎么修改
查看完整描述

3 回答

已采納
?
Bran_Zuo

TA貢獻(xiàn)3條經(jīng)驗 獲得超1個贊

for循環(huán)里執(zhí)行return只是退出循環(huán),但是getMaxAge方法并沒有返回語句,應(yīng)將return語句放在for循環(huán)外

public?class?helloworld?{
????public?static?void?main(String[]?args)?
????{
????????helloworld?hello?=?new?helloworld();?
????????int?maxScore=hello.getMaxAge();
????????//?輸出最大年齡
????????System.out.println("最大年齡為:"?+?maxScore);?
????}
????public?int?getMaxAge()
????{
????????int?[]ages={18,23,21,19,25,29,17};
????????int?max=ages[0];
????????for(int?i=0;i<ages.length;i++)
????????{
????????????if(ages[i]>max);
???????????????max=ages[i]?;
????????}
????????return?max;
????}
}


查看完整回答
反對 回復(fù) 2016-12-12
?
Its_forever

TA貢獻(xiàn)361條經(jīng)驗 獲得超328個贊

? ? ? return max;放到括號之后。

public?int?getMaxAge(){

int?[]ages={18,23,21,19,25,29,17};
????int?max=ages[0];
????for(int?i=0;i<ages.length;i++){
????????if(ages[i]>max);
??????max=ages[i]?;
??????
????}
????return?max;
????}


查看完整回答
反對 回復(fù) 2016-12-11
?
張旖旎

TA貢獻(xiàn)1條經(jīng)驗 獲得超0個贊

缺少返回值吧。在你定義的public int getMaxAge()這個方法里。你可以return一個要的數(shù)據(jù)就不會錯了

查看完整回答
反對 回復(fù) 2016-12-11
  • 3 回答
  • 0 關(guān)注
  • 1946 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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