huzhihui1 2017-12-03 08:00 采纳率: 100%
浏览 1705
已采纳

关于return返回值的问题,求大神解释

public class Student {
private String name;
private int age;
private int score;
public Student() {
super();
}
public Student(String name, int age, int score) {
this.name = name;
this.age = age;
this.score = score;
}
。。。。。。。
}
public class StudentsTool {
public int getMaxScore(Student[] arr) {//:获取学生成绩的最高分
int max=0;
for (int i = 0; i < arr.length-1; i++) {
Student student = arr[i];
int score=student.getScore();
if(score>max) {
max=score;
}
}
System.out.println("学生最高成绩为:"+max);
return max;
}
public class TestStudentTool {
public static void main(String[] args) {
// TODO Auto-generated method stub
Student s1=new Student("小明",22,68);
Student s2=new Student("小强",21,70);
Student s3=new Student("小翟",22,90);
Student s4=new Student("小杨",25,59);
Student s5=new Student("小刘",24,48);
Student[] arr2={s1,s2,s3,s4,s5};
StudentsTool a=new StudentsTool();
a.getMaxScore(arr2);
此程序中函数getMaxScore()里面的return后面跟的返回参数对程序一点影响都没有,输出全靠System语句,这是为什么?

  • 写回答

2条回答 默认 最新

  • mvpxgx 2017-12-03 08:06
    关注

    因为输出在方法体中getMaxScore,在return前面,你也没用变量接收啊

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于双目测规则物体尺寸
  • ¥15 wegame打不开英雄联盟
  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,