使用对象数组作为参数(对象数组类型的参数) |
您所在的位置:网站首页 › 数组如何作为函数的参数使用 › 使用对象数组作为参数(对象数组类型的参数) |
import java.util.Scanner; //学生类class Student{ int age;} //平均年龄class Age{ public int avg_Age(Student[] st){ int avgage = 0; //平均年龄 int all = 0; //学生总年龄 int count = 0; //学生计数 for(int i=0; i public static void main(String[] args){ Student[] stu = new Student[5]; //定义包含五个元素的学生对象数组(注意并没有为其分配空间) Age test = new Age(); Scanner input = new Scanner(System.in); for(int i=0; i |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |