Sponsored Link •
|
Advertisement
|
Advertisement
|
This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.
Message:
Hi, Kishori. Thanks for such a good answer, now i understand why it did not work. But i do not understand why the solution (in fact it's more an evasion than a solution) i found some days ago does work: Mapped to the example we used, i did the following: I put the method protected B newB(String s, boolean b){ return new B(s,b);} in class A and the method-call B b1 = this.newB(s,b); in the method f of class C (i will put the complete code of this classes to the bottom of this posting.) Definitively: If i overwrite the method newB(...) in C with the same code as in A (so it should not change anything), the compiler complains. I cannot decide whether this is a lack of understanding on my side or a not-so-lucky-design-feature of java, or if it even is wanted behaviour a i am not able to see why it is wanted. Thank you,
--> Class A: <-- package apack; public class A { protected class B { //That's my 'evasion-method' }
package cpack; import apack.A; public class C extends A { public static void main ( String[] args ) { } //Delete the '//' in the following lines to annoy the Compiler }
Replies:
|
Sponsored Links
|