could anyone help with this... I'm calling a super class method.Now, i want this method to call other super class methods..instead it calls the subclass method.(all methods in the superclass are overridden in the subclass). the expected ouput is - in C.m1 in P.m2 in P.m1 instead it goes in a loop... in C.m1 in P.m2 in C.m1 in P.m2.... following is the code - class P { public void m1() { System.out.println("In P.m1()"); } public void m2() { System.out.println("In P.m2()"); m1(); } } public class C extends P { public void m1() { System.out.println("In C.m1()"); super.m2(); }
public void m2() { System.out.println("In C.m2()"); } public static void main(String[] args) { C c = new C(); c.m1(); } }
Chris Harris
Ranch Hand
Joined: Sep 21, 2003
Posts: 231
posted
0
This topic has been crossed post and has been answered in "Java in General (intermediate)". [ added link -ds ] [ January 08, 2004: Message edited by: Dirk Schreckmann ]
SCJP 1.2, SCWCD, SCBCD
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
posted
0
Thanks for the heads up, Chris. kau, please don't post the same question in multiple forums. It just makes it difficult to follow a conversation and uses Ranchers' efforts needlessly. I'm closing this thread.