Files
java-cui-em-oop/em-oop/src/Student.java
2026-09-24 11:18:16 +09:00

26 lines
521 B
Java

public class Student {
//変数を作る
int studentId;
String name;
//フィールド追加
static int studentCount = 0;
//コンストラクタ追加
public Student(int studentId,String name) {
this.studentId = studentId;
this.name = name;
studentCount++;
}
//メソッド追加
public static int getStudentCount() {
return studentCount;
}
//メソッド
public void printProfile() {
System.out.println("学籍番号:" + this.studentId + " 名前:" + this.name);
}
}