View Single Post
  #8 (permalink)  
Old 06-13-2007, 05:04 AM
oubless oubless is offline
Newbie
 
Join Date: May 2007
Posts: 22
Rep Power: 6
oubless is on a distinguished road
Default

Quote:
Originally Posted by Spitfire View Post
Question oubless, what use is there having a class inside the other class if they cant share methods and the like. Wouldnt it make more sense to just have them in seperate classes? Unless it was just to categorize... Alphabet.Vowel.method(); thats the only use i can really see for it. Sorry i have alot of daft questions
Read about inner classes - they are pretty strong as a concept...
You can use them to mimic multiple inheritance ( as you know it is not allowed in Java ). The inner class has access to ALL !!! fields and methods of the class it is nested in ( including private ones ).
I just googled those for you:
Java Tip 106: Static inner classes for fun and profit - Java World
Inner classes - Java World
Nested Classes (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
Inner Class Example (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
Unfortunately there is no tutorial here about inner class ( or at least I didn't spotted any ) ... and as Sidewinder is author of most of them, try asking him to write one about inner classes. I just don't have enough time for this right now, sorry
Reply With Quote