1.2 对象是类的一个具体实现
1.3例如:
汽车模型和生产出来的汽车
猫和我家的那只猫
1.4 实例
人骑车
public class Test3
{
public static void main(String[] args)
{
Person p = new Person();
Bike b = new Bike();
p.ride(b);
}
}
class Person
{
public void ride(Bike b)
{
b.run();
}
}
class Bike
{
public void run()
{
System.out.println("bike is running");
}
}
该博客教程视频地址:http://geek99.com/node/1601