We've done favorites before, but it would be fun to do again since we have guest authors here.
Mine is autoclosing resources.
I learned while reading "Java 7 New Features Cookbook" that the JavaDocs are Section 508 compliant starting Java 7. (Section 508 is an accessibility standard.) I think this is really cool so wanted to mention it in this thread anyway.
But I also think the feature of not repeating the declaration for Generics on both the sides of the declaration reduces the verbosity to some extent. And even Autoclosing would help in reducing the amount of code written.
Then there's a new Concurrency related feature (Fork-Join) and I think even that might be useful, but I dont know how ;)
My personal favorite (and favorite recipe to write for our book) is the ability to manage the shape of a window in GUI applications, though I will admit this was more of a fun feature than something I have found particularly useful! From a more practical standpoint, I appreciate the simplicity of the Files class and Path interface for file I/O. Working with files and directories is greatly simplified in Java 7.
I've written systems multiple times where there had to be some process that checks regularly if a file is placed in a directory, which should then be picked up to be processed. You could do that by having a scheduled task that every X seconds or so lists the files in the directory to see if anything has appeared.
Java 7 has a new feature where you can ask to be notified when something changes in a directory. See Watching a Directory for Changes. Instead of polling, it will use the native functionality of the operating system for file system change notifications, which is most likely much more efficient than polling.
So, that's one of the new features that seems really useful to me.
1. try-with-resources (autoclose feature) - it takes boilerplate code of maintaining Streams/Connection out of scope for us
2. Diamond operator - makes code looks more better now
3. String in switch - aren't we missing this feature in Java since long ?
Oracle certified Java 8 Programmer I (1Z0-808), Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I, CIW Certified Ecommerce specialist