根据下面这个程序,我认为编译后的字节码中也应该含有Object相关的字节码的- public class GetParentClass {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Class<?> room2Class = Room2.class.getSuperclass();//从Room2的字节码中获取其默认的父类
- System.out.println(room2Class); //结果为class java.lang.Object
- }
- }
- class Room2{//默认继承Object类
- private String id;
- private int price;
- public String getId() {
- return id;
- }
- public void setId(String id) {
- this.id = id;
- }
- public int getPrice() {
- return price;
- }
- public void setPrice(int price) {
- this.price = price;
- }
- public Room2(String id, int price) {
- super();
- this.id = id;
- this.price = price;
- }
- }
复制代码 |