Part 1. Developing with Java 7
These first two chapters are about ramping up with Java 7. You’ll ease in with an introductory chapter that covers some small syntax changes that will increase your productivity—all of which punch above their weight. This will set the stage for the larger topic in this part—a chapter on new I/O in Java.
The well-grounded Java developer needs to be aware of the latest language features available. Java 7 comes with several new features that will make your life as a working developer much easier. But it isn’t enough simply to understand the syntax of these new changes. In order to write efficient and safe code quickly, you need an in-depth understanding of how and why the new features were implemented. The Java 7 language changes can be roughly split into two sets: Project Coin and NIO.2.
The first set is known as Project Coin, a group of small language-level changes that were designed to increase developer productivity without heavily impacting the underlying platform. These changes include:
- A try-with-resources construct (which automatically closes off resources)
- Strings in switch
- Enhanced numeric literals
- Multi-catch (declare multiple exceptions in a catch block)
- Diamond syntax (requiring less boilerplate when dealing with generics)
Each of these changes may seem small, but exploring the semantics behind the simple syntax changes also gives you extra insight into the split between Java the language and Java the platform.