Multiple classes in the same source file

I'm not sure what this is called, having multiple classes in the same source file. At first I thought it ws called subclassing but then I googled it and found that subclasses are just derived classes. Here's an example of what I'm talking about.

publicclass A{

}

class B{

}

class C{

}

So first of all, what is having multiple classes in the same source file called?

Secondly, what are the advantages/disadvantages of this?

Thirdly, can you have a class completely WITHIN a class (same source file but inside the class not outside) and what are the advantages/disadvantages of this?

[938 byte] By [dynobirda] at [2007-10-2 6:04:32]
# 1

Advantage: You can reduce the number of source files specialy when your secondry classes are used only in the public class of the file.

Disadvantage: Normaly it make things more clear if we have one-to-one correspondance of class and source files. This make things easy when you want to find the java file of a perticuler class file. Also If you later wanted to create a seperate public class with a same name as one of those secondry classes you got lots of changes to do.

You can avoid this by creating them as nested classes

ex:-

public class MyPublicClass{

private static class MyInnerClass{

}

}

this way the inner class will create a class file with name "MyPublicClass$MyInnerClass.class" instead of just "MyInnerClass.class"

And also if you declare the inner class as public you can access them from out side

LRMKa at 2007-7-16 13:05:02 > top of Java-index,Java Essentials,Java Programming...