為什么我的運(yùn)行不了呢
public class test {
? ??
? ? //完成 main 方法
? ? public static void main(String[] args) {
? ? ? ??
? ? ? ? // 創(chuàng)建對(duì)象,對(duì)象名為hello
test hello = new test();?
? ? ? ??
? ? ? ? // 調(diào)用方法并將返回值保存在變量中
? ? ? ? int maxScore= hello.getMaxAge();
?
// 輸出最大年齡
System.out.println("最大年齡為:" + maxScore);?
}
public int getMaxAge() {
//方法中將學(xué)生年齡保存在數(shù)組 ages 中,數(shù)組元素依次為 18 ,23 ,21 ,19 ,25 ,29 ,17
int[] ages={18,23,21,19,25,17};
int max=ages[0];
for(int i=0; i<ages.length; i++){
if(ages[i]>max){
max=ages[i];
}
}
//返回值
return max;
??
}
}
2015-12-15
去檢查jdk安裝或者環(huán)境變量有問(wèn)題嗎