• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

why don't protected inner class compile?

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have a three .java files followed:

when i compiling the LittleDog,show the WhiteDog() has protected access in the myclass2.Dog.WhiteDog
How can I access the WhiteDog in the LittleDog.java
[ June 11, 2003: Message edited by: zhang feng ]
[ June 11, 2003: Message edited by: zhang feng ]
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi zhang,
Welcome to JavaRanch. First off you had several other problems in your code. For your question, since you did not provide a public default constructor for WhiteDog, the compiler created a protected default constructor which is the access level of the enclosing class. LittleDog has no relationship to WhiteDog, so it can only access WhiteDog's public memebers. All you have to do to fix the problem is provide a default public constructor. I fixed some of your code here:
Animal.java


Dog.java

LittleDog.java
 
zhang feng
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh,it's running good ,thank you
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic