now my question is , how to create an object of the inner class which has access type protected ( as seen in above example ) in some other package ? I tried code as seen below but didn't worked , please help.....
Well, let's see if you can solve it. It usually helps if you read the error message. For example, here is the code I used to test:
When I tried to compile Maker, this is the error message:
The error message tells you that Inner() [That's the Constructor for the Inner class] has protected access, which means, since Maker does not extend Inner, it can not access Inner() [and therefore can't make a new instance of the Inner class].
There are two solutions to this problem, one involves changing Inner slightly, the other involves adding a new class (inside Maker). Can you come up with the solutions?
Joined: Jun 17, 2009
i got it , please go though it
Parent class in a package which has the inner class with access type protected
the child class in other package
the above code compiles and runs , but what about the first solution you wrote about modifying the inner class which is in parent class , this i didn't understood
can you please elaborate on this hint