Originally posted by Shelly Biswal:
cant i ve same class names in two different java files???
Not if they are in the same package as well.
Imagine the situation where you have two (non-public) classes in two different files with the same fully qualified name (so same package etc). Then you want to use that class. But which one?
That's why I put all classes of my (real, non-test) code in separate files, so this problem can never arise.
Please note that you can still have the same name if they are in different packages, like java.awt.List and java.util.List, or if they are in the any package but at least one of them is a nested class like javax.swing.text.html.Parser and javax.swing.text.html.HTMLEditorKit.Parser. The first is a top level class, the second is a nested class inside top level class HTMLEditorKit.