http://www.developer.com/java/article.php/3864871/The-Java-7-Features-Bound-to-Make-Developers-More-Productive.htm
If you've tracked each major Java release, you probably were eager to see what new packages were in each one and how you could employ them in your Java projects. Along the same lines, the next major Java SE release, Java 7, promises several new features across all packages, such as modularization, multi-language support, developer productivity tools, and performance improvement. I think programmers eventually will begin specializing in individual Java packages (i.e., java.util programmers, java.io programmers, java.lang programmers, etc.), but until then, let's explore a few of the notable new developer productivity features slated for Java 7. Find examples of all the features discussed here in the code download for this article. The new Objects class of the java.util package provides a fail-proof way for comparing two objects at runtime: Similarly, when both the arguments are object arrays, Java SE 7 provides classes that greatly simplify the age old integration processes of one application dropping files at a predefined shared location and other application picking them up. Java 7 provides a new class WatchService that notifies any events that take place in the file system under the watch. The following steps create an asynchronous file-watcher service: The Java SE team added a wide variety of new classes to Java 7 to cater to various concurrency functionalities. Most notable among them are the RecursiveAction and RecursiveTask classes, which simplify new algorithm development. Understanding the difference between heavyweight and lightweight processes will help you grasp the value of these new classes. Java 7 defines a new abstract class called ForkJoinTask, a lightweight process that generates a distinct stream of control flow from within a process. RecursiveAction and RecursiveTask are abstract subclasses of ForkJoinTask. To code a recursive call, you must subclass either one of these classes and define the For me, the joy of being a computer scientist is spending long hours writing code for various algorithms. The problem solving keeps my mind alert, and the computations keep going in my head even in sleep. All the utilities in Java 7 take much of that joy of programming away, but they contribute to the bottom line for the companies supporting Java projects, which is what really matters for Java.
The Java 7 Features Bound to Make Developers More Productive
February 12, 2010
New Objects Class
equals() method of the Objects class does a reference comparison.
deepEquals() method piggybacks on the first argument's equals() method definition. Array.deepEquals() is invoked on the objects. The new Objects class provides all the required static utility methods.New Classes to Operate on File System
Path fPath = new File(filePath).toPath();
dirWatcher = fPath.getFileSystem().newWatchService();
fPath.register(dirWatcher,
StandardWatchEventKind.ENTRY_CREATE,
StandardWatchEventKind.ENTRY_DELETE, StandardWatchEventKind.ENTRY_MODIFY);
try{
WatchKey key = dirWatcher.take();
}catch(InterruptedException ie){
return;
}
The WatchKey class now has all the details of the event that occurred in the directory.
New Classes for Concurrency Package
fork().
compute() method. The getRawResult() method returns null for RecursiveAction and returns a value for RecursiveTask. The Java 7 documentation provides a simple example for each of these classes.Code Development Made Too Easy?
Code Download
For Further Reading
About the Author
Raghu Donepudi is an independent contractor working as a Technical Manager for a U.S. Federal Government agency. He holds a master's degree in Computer Science from Lamar University in Beaumont, TX. Raghu is also a Sun-certified Java developer and the author of innovative software design techniques.