public class override { public static void main(String[] args) { c1 obj = new c1(); System.out.println(obj); } } class a1 { public String toString (){ return "this is clas a"; } } class b1 extends a1{ public String toString (){ return "this is clas b"; } } class c1 extends b1{ public String toString (){ return super.toString() + "\nthis is clas c"; } }
I need to access the superclass a1
toString
method in c1
subclass. Is there any way to do it. I'm learning java, any help would be a great support.
没有评论:
发表评论