When I first learned about import static (introduced in JDK 1.5), I thought it was something that I would never use. I still think I'll never use a wildcard import static.
However, there were a bunch of classes that extended one abstract class, and I wanted to change to extend another abstract class. Those classes used a bunch of static methods in the original abstract class, so, at first, I started changing each reference to be prefixed with the original class. After a while of this stupidity, I remembered the import static feature, and that made the change a lot easier.
Another import feature that I sometimes want is an "import as" feature. Something like
import java.sql.Date : SQLDate;
or
import SQLDate = java.sql.Date;
because java.sql.Date and java.util.Date can't both be imported.
No comments:
Post a Comment