package lianxi; public class XiYouJiRenWu { String Name; double Height; String Weapon; void printName() { System.out.println(Name); } void printWeapon() { System.out.println("武器: "+Weapon); } }
public static void main(String[] args) { XiYouJiRenWu XiYouJiRenWu1=new XiYouJiRenWu(); XiYouJiRenWu1.Name="孙悟空"; XiYouJiRenWu1.Weapon="金箍棒"; XiYouJiRenWu1.printName(); XiYouJiRenWu1.printWeapon(); XiYouJiRenWu XiYouJiRenWu2=new XiYouJiRenWu(); XiYouJiRenWu2.Name="猪八戒"; XiYouJiRenWu2.Weapon="九齿钉耙"; XiYouJiRenWu2.printName(); XiYouJiRenWu2.printWeapon(); }