03 2012 档案
继续画图形
摘要:package polymorphism;public class Shapes{ void draw(){} void erase(){}} package polymorphism;public class Square extends Shapes {public void draw(){System.out.println("Square.draw");}public void erase(){System.out.println("Square.erase");}}package polymorphism;public class riangl 阅读全文
posted @ 2012-03-08 23:18 心中的她 阅读(140) 评论(0) 推荐(0)
继承构造器
摘要:1,类A继承类B,如果类A里面也就同时拥有了A,B两个构造器,并且是先运行基类的构造器3,如果B类里面的构造器是带有参数的,那么A类调用B的时候,必须在自己的构造器类调用super的发放,并传递参数。package text;public class tex1 extends tex2{tex1(){ super(11);}public static void main(String args[]){ tex1 x=new tex1(); } }class tex3 {tex3(int i){System.out.println("我是基类");System.out.pri 阅读全文
posted @ 2012-03-04 20:09 心中的她 阅读(157) 评论(0) 推荐(0)
toString
摘要:每一个非基本类型的对象都有一个toString 的方法,当编译器需要一个String类型而你只有一个对象的时候这个方法便会被调用如package text;public class text1 { public static void main(String args[]){text12 tex=new text12(); System.out.println(tex); }} class text12{private String i="b"; text1 a=new text1(); public String toString(){ return "+i=& 阅读全文
posted @ 2012-03-03 14:36 心中的她 阅读(158) 评论(0) 推荐(0)