Wednesday, 18 July 2007

Static imports in Java 5

Java 5 added an import static option that allows static variables (typically constants) to be referenced without qualifying them with a class name. For example, after import static java.awt.Color;
It would then be possible to write Color background = RED;
instead of Color background = Color.RED;
Adding this "feature" wasn't the best idea because it leads to name pollution and confusion about which class constants come from. Even Sun (see References below) basically advises not to use it!

No comments:

Can Jackson Deserialize Java Time ZonedDateTime

Yes, but must include JSR310. Thus ZonedDateTime can be deserialized directly from JSON response to POJO field. <dependency> <g...