package com.cunyu.demo
public class Demo {
private String name; //成員變量、執行個體變量
private int age; //成員變量、執行個體變量
private int ID; //成員變量、執行個體變量
public static final String school = "卡塞爾學院"; //成員變量、靜态變量(類變量)
public static String level = "SSS"; //成員變量、靜态變量(類變量)
public int getAge() {
return age;
}
public int getId() {
return ID;
}
public String getName() {
return name;
}
public void setAge(int age) {
this.age = age;
}
public void setId(int ID) {
this.ID = ID;
}
public void setName(String name) {
this.name = name;
}
public void study(){
String subject1 = "屠龍"; //局部變量
String subject2 = "煉金術"; //局部變量
System.out.println("學習科目: " + subject1 + "、" + subject2);
}
public static void main(String[] args) {
Demo demo = new Demo();
demo.setAge(23);
demo.setId(14000001);
demo.setName("楚子航");
System.out.println("ID: " + demo.getId() + "Age: " + demo.getAge() + "Name: " + demo.getName());
System.out.print("主修科目: ");
demo.study();
System.out.println("學院:" + Demo.school);
System.out.println("等級:" + Demo.level);
}
}