The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
December 2000



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.


It works, but if ...

Posted by Christian Schmitt on December 11, 2000 at 8:46 AM

Hi Kishori.

First of all: Thanks for the time you spent on my problem so far!

The code you posted compiles and works with my jdk too (1.2.2, i can't switch to 1.3 because i'm at work and i've got to comply with regulations).

Please try the following:
Put A and C in different files and those two files in different packages, and test it again.

If i've got it right, not only classes in the same package but also inherited classes should have the right to access things (methods, fields, inner classes) declared 'protected', so there should be no problem for C to instantiate B. But there is. Am i wrong?

Again: thank you,

  • Good question!!! Kishori Sharan December 11, 2000 at 10:33 AM (2)
    • one more... Christian Schmitt December 13, 2000 at 9:01 AM (1)
      • U got it... Kishori Sharan December 13, 2000 at 2:24 PM (0)

Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us