正在加载图片...
Java实例_(续) class Rectangle extends Shape{ public static void main(String args[]){ int width=30,height=10; Rectangle tt=new Rectangle();//创建对象时要引用构造方法 tt.x=width; tt.y=height; tt.measure(); /width=tt.m; 对于Rectangle子类不能继承父类的私有成员变量 的值,所以此语句会产生语法错误*/ /height=tt.n; 与上相同 /tt.show(); //不能引用show()私有方法Java实例——(续) class Rectangle extends Shape{ public static void main(String args[]){ int width=30,height=10; Rectangle tt=new Rectangle(); //创建对象时要引用构造方法 tt.x=width; tt.y=height; tt.measure(); /* width=tt.m; 对于Rectangle子类不能继承父类的私有成员变量 的值,所以此语句会产生语法错误*/ // height=tt.n; 与上相同 // tt.show(); //不能引用show()私有方法 } }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有