首页上一页 1 下一页尾页 1 条记录 1/1页
Members members = new Members(60, 10);这一行代码怎么理解
发表在Java图书答疑
2019-08-30 悬赏:1 学分
《零基础学Java》第7章 面向对象核心技术 184页-185页
是否精华
是
否
版块置顶:
是
否
public class SchoolClass {
Members members = new Members(60, 10);
class Members {
int maxStudentsNum;
int maxTeachersNum;
public Members(int maxStudentsNum, int maxTeachersNum) {
this.maxStudentsNum = maxStudentsNum;
this.maxTeachersNum = maxTeachersNum;
}
public void setValue() {
System.out.println("一个班级,老师的数量最多" + maxTeachersNum + "人,学生的数量最多" + maxStudentsNum + "人。");
}
}
public static void main(String[] args) {
SchoolClass schoolClass = new SchoolClass();
schoolClass.members.setValue();
}
} class Members { int maxStudentsNum; int maxTeachersNum; public Members(int maxStudentsNum, int maxTeachersNum) { this.maxStudentsNum = maxStudentsNum; this.maxTeachersNum = maxTeachersNum; } public void setValue() { System.out.println("一个班级,老师的数量最多" + maxTeachersNum + "人,学生的数量最多" + maxStudentsNum + "人。"); } } public static void main(String[] args) { SchoolClass schoolClass = new SchoolClass(); schoolClass.members.setValue(); } }