Despite the gnashing of teeth in 2009 when Oracle bought Sun Microsystems, Sun’s stewardship of Java seems to have passed, with very little turbulence, into capable hands. The language continues to evolve to address the productivity needs and desires of end users and mesh with the new computing models driven by the growth in web applications, mobile devices, and advances in hardware design and enterprise architectures.

Merriam Webster defines a hacker as BOTH “a person who is inexperienced or unskilled at a particular activity” and “an expert at programming and solving problems with a computer”. Now, to some that may sound contradictory, but I believe it accurately bounds my Java skills. Somewhere in between, depending on how long it has been since I dove into a project. True Java professionals deserve all the praise they get ++. We hackers, though, tend to write programs on an as-needed basis, never quite attaining the distinction of being “adept”. And never having to face production deadlines for bullet-proof code. So that’s my excuse for taking a few months to get around to using some of the new features in Java 7, on which I’ll comment below.

  • Switch Statements

We can now switch with strings! Switch statements are the alternative to multiple “if elseif elseif elseif” constructs. Rather than using obtuse integers to specify each case, we first declare the case to be a string and then use an actual word to identify the case. This can result in cleaner and more readable code. Very nice when passing arguments.

  • Numeric literals now with underscores

When I first saw this, I thought “how nice”. Now it doesn’t matter how blurry my eyes are, I can still tell that the order of magnitude is correct. If there was ever a concession to late-night coding errors, this is it. Not a New York Times above-the-fold-item, but very, very nice. And thoughtful. For example…

int notsobig = 1000; can now become int notsobig = 1_000; and int prettybig = 1000000; can become int prettybig = 1_000_000; and int wowthatsbig = 1_000_000_000_000;

  • Multiple exceptions

Another nice feature that improves code readability is the way multiple exceptions can now be handled. Instead of having a catch statement for each exception you can now catch them all in one block using a pipe separator. No more catch catch catch catch.

So those are three fairly easy-to-explain changes in Java 7. To download your copy of Oracle Java 7 and the latest NetBeans IDE (my preference over Eclipse) in one bundle and no fee, go to Oracle’s main Java website

Oh, one more thing; I have not tried using it yet but Java 7 includes JavaFX that you can use to write your own Android app – for the world, or to surprise your family (think of the fun you could have) and amuse your colleagues. Go for it!

blogs@www.dlt.com'
Rick Marcotte