Yet the compiler allows both classes to have the same name. Because they are in different packages, and the fully qualified name of each class includes the package name. That is, the fully qualified name of the Rectangle class in the graphics package is graphics. Rectangle , and the fully qualified name of the Rectangle class in the java.awt package is java.awt.Rectangle . This generally works just fine unless two independent programmers use the same name for their packages.
Some companies now choose to drop the first element com.