典型的例子很多,比如: 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(); } } }