In my project I have a shapes
package which has shapes I designed for my graphics program e.g Rectangle, Circle. I also have one or two more packages that have the
I don't get all the non-answers posted here.
Yes, individual imports are a bad idea, and add little, if anything, of value.
Instead just explicitly import the conflicts with the class you want to use (The compiler will tell you about conflicts between the awt
and shapes
package.) like this:
import java.awt.*;
import shapes.*;
import shapes.Rectangle; // new Rectangle, and Rectangle.xxx will use shapes.Rectangle.
This has been done for years, since Java 1.2, with awt
and util
List
classes. If you occasionally want to use java.awt.Rectangle
, well, use the full class name, e.g., new java.awt.Rectangle(...);
.