典型的例子不少,好比: class Human { public void breath() { Air freshAir = new Air(); freshAir.releasePower(); } public static void main() { Human me = new Human(); while(true) { me.breath(); } } }
class Air { public void releasePower() { //do sth. } }
典型的例子不少,好比: class Human { ArrayList friends = new ArrayList(); public void makeFriend(Human human) { friends.add(human); } public static void main() { Human me = new Human(); while(true) { me.makeFriend(mySchool.getStudent()); } } }
典型的例子不少,好比: class Human { Home myHome; public void goHome() { //在回家的路上 myHome.openDoor(); //看電視 } public static void main() { Human me = new Human(); while(true) { //上學 //吃飯 me.goHome(); } } }