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

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

請大家?guī)臀铱纯村e在哪里了~謝謝

請大家?guī)臀铱纯村e在哪里了~謝謝

kathria 2016-09-07 15:54:10
package com.imooc;public class helloWorld {?? ???? //完成 main 方法??? public static void main(String[] args) {?????? ??????? ???????? // 創(chuàng)建對象,對象名為hello?? ??? ?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;??????? }?? ?}}
查看完整描述

1 回答

已采納
?
阿旭_

TA貢獻217條經(jīng)驗 獲得超353個贊

方法不能嵌套方法:即:main()不能嵌套getMaxAge()

換好位置,結果如下:

package?com.imooc;

public?class?helloWorld?{

	//?完成?main?方法
	public?static?void?main(String[]?args)?{
		//?創(chuàng)建對象,對象名為hello
		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;
	}
}

http://img1.sycdn.imooc.com//57cfccf80001305d02930104.jpg

查看完整回答
2 反對 回復 2016-09-07
  • 1 回答
  • 0 關注
  • 1128 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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