This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
If you search this forum, you should get plenty of discussions on this topic.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Justin Fox: i believe you would save it as A.java, but have B as a subclass of A
no, you would not. The language specs state quite explicitly that you can AT MOST ONE public class in a sourcefile and that if ther is such a public class the sourcefile MUST have the name of that class.
You can, though, have as many public nested and inner classes as you like.
You shouldn't use this to bypass the "one public class per file" rule - you should use nested or inner classes only when they really are strongly related to the enclosing class. I think public nested or inner classes are only occasionally a good idea. In contrast, private ones are often useful.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
The old Oak 0.2 specification appears to suggest this was a performance optimization...
Although each Oak compilation unit can contain multiple classes or interfaces, at most one class or interface per compilation unit can be public... This restriction is ... necessary for efficient package importation.