- public class Ch87 {
- public static void main(String[] args)
- {
- Family man=new Family("爸爸",40,"爬山");
- Family woman=new Family("媽媽",37,"逛街");
- Family boy=new Family("弟弟",10,"打電動");
- Family girl=new Family("妹妹",8,"看書");
- man.showProFile();
- woman.showProFile();
- boy.showProFile();
- girl.showProFile();
- }
- }
- class Family
- {
- String name,d;
- int age;
- Family(String a ,int b, String c)
- {
- name=a;
- age=b;
- d=c;
- }
- void showProFile()
- {
- System.out.println(name+"今年"+age+"歲,喜歡"+d);
- }
- }
複製代碼 |