This commit is contained in:
louiscklaw
2025-01-31 19:15:17 +08:00
parent 09adae8c8e
commit 6c60a73f30
1546 changed files with 286918 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
public class Ex8 {
public static void main(String[] args) {
Student stu1 = new Student("John Chan"); //line 10
System.out.println(Student.numberOfStudent); //line 11
System.out.println(stu1.name); //line 12
}
}

View File

@@ -0,0 +1,17 @@
public class Student {
public static int numberOfStudent=0; //line 1
public String name; //line 2
public Student (String name) { //line 3
numberOfStudent++ ; //line 4
setName(name); //line 5
}
public int getNumberOfStudent() { //line 6
return numberOfStudent; //line 7
}
public void setName(String name) { //line 8
this.name = name; //line 9
}
}