返回列表 發帖
  1. class Student{
  2.        
  3.         public String name;
  4.         public int score;
  5.        
  6.        
  7.         Student(String name, int score)//建構子
  8.         {      
  9.               this.name=name;
  10.           this.score=score;               
  11.         }
  12.         public String getName()
  13.         {
  14.                 return name;
  15.         }
  16.         public void setScore(int score)
  17.         {
  18.                 this.score=score;
  19.         }
  20.         public static void halloWorld()
  21.         {
  22.                 System.out.println("Hallo World!");
  23.         }
  24. }

  25. public class Main {
  26.         public static void main(String[] args) {
  27.               Student William = new Student("威廉",87);
  28.           Student Mary = new Student("瑪莉",69);
  29.           Student.halloWorld();
  30.         }

  31. }
複製代碼

TOP

返回列表