The Java Virtual Machine does not require any particular internal structure for objects. In Sun's current implementation of the Java Virtual Machine, a reference to a class instance is a pointer to a handle that is itself a pair of pointers: one to a table containing the methods of the object and a pointer to the Class object that represents the type of the object, and the other to the memory allocated from the Java heap for the object data. (jvm规范中关于对象内存布局的说明)
作者: 李盈科 时间: 2011-12-31 16:14
多态主要体现 就是父类引用可以指向子类的对象,从而调用子类的方法, 如果按现实来说,男人就是人,java具体体现的方法重载和重写。作者: 付星 时间: 2011-12-31 17:05
多态是父类的引用指向子类,或接口类型指向实现了这个接口的实现类
下面一个简单的例子
class Person
{
}
interface Can
{
}
class Student extends Person implements Can
{
}
public class Test
{
public static void main(Stirng[] args){
Person s=new Student();//父类的引用指向子类
Can s=new Student();//接口类型指向实现了这个接口的实现类
}
}