3. Strings in switch statements
String status = offer.getStatus();
switch(status) {
case NEW:
newOffer(offer); Case Label
break;
case PENDING: toString()
pendingOffer(offer);
break;
default:
break;
}
4. Automatic Resource
Management
Automatic close Multiple Resources
try(FileOutputStream fos = new FileOutputStream(“movies.txt”);
DataOutputStream dos = new DataOutputStream(fos)) {
dos.writeUTF(“Java 7 New Features”)
} catch (IOException e) {
...
}
Implements java.lang.AutoCloseable
try-with-resources statement
8. NIO 2.0
● Working with Path: Path, Paths,
FileSystem, FileSystems, ...
● File change notifications: WatchService,
WatchKey
9. Fork and Join Framework
● ForkJoinPool int numberOfProcessors =
Runtime.getRunTime().availableProcessors();
● RecursiveAction ForkJoinPool pool = new
(void compute()) ForkJoinPool(numberOfProcessors)
…
● RecursiveTask<V>
public class BigProblemTask extends
(V compute()) RecursiveAction {
@Override
protected void compute() {
// your problem invocation goes here
}
}
…
pool.invoke(task);