Files
em-oop/Student.java
2026-10-15 16:30:26 +09:00

31 lines
544 B
Java

package misson1014;
public class Student {
int studentId;
String name;
//staticフィールド
static int studentCount = 0;
//コンストラクタ
public Student(int studentId, String name) {
//フィールド代入
this.studentId = studentId;
this.name = name;
studentCount++;
}
//学生情報
void printProfile() {
System.out.println(
"学籍番号:" + this.studentId
+ " 名前:" + this.name);
}
//現在の学生数用staticメソッド
public static int getStudentCount() {
return studentCount;
}
}