为什么我的运行不了呢

来源:6-1 什么是数组

菜菜0123456

2015-12-15 18:53

public class test {

    

    //完成 main 方法

    public static void main(String[] args) {

        

        // 创建对象,对象名为hello

test hello = new test(); 

        

        // 调用方法并将返回值保存在变量中

        int maxScore= hello.getMaxAge();

 

// 输出最大年龄

System.out.println("最大年龄为:" + maxScore); 

}


public int getMaxAge() {

//方法中将学生年龄保存在数组 ages 中,数组元素依次为 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;

  

}

}


写回答 关注

1回答

  • 爱与恨
    2015-12-15 19:24:12
    已采纳

    去检查jdk安装或者环境变量有问题吗

    菜菜0123...

    非常感谢!

    2015-12-16 14:44:01

    共 1 条回复 >

Java入门第一季(IDEA工具)升级版

0基础萌新入门第一课,从Java环境搭建、工具使用、基础语法开始

1163370 学习 · 17551 问题

查看课程

相似问题