- class Student{
-
- public String name;
- public int score;
-
-
- Student(String name, int score)//建構子
- {
- this.name=name;
- this.score=score;
- }
- public String getName()
- {
- return name;
- }
- public void setScore(int score)
- {
- this.score=score;
- }
- public static void halloWorld()
- {
- System.out.println("Hallo World!");
- }
- }
- public class Main {
- public static void main(String[] args) {
- Student William = new Student("威廉",87);
- Student Mary = new Student("瑪莉",69);
- Student.halloWorld();
- }
- }
複製代碼 |