Java 8
- forEach() method in Iterable interface
- default and static methods in Interfaces
- Functional Interfaces and Lambda Expressions
- Java Stream API for Bulk Data Operations on Collections
- Java Time API
- Collection API improvements
- Concurrency API improvements
- Java IO improvements
- Miscellaneous Core API improvements
It will be good if having knowledge on below areas :
1) Basic Java programming
2) Basic knowledge of the main APIs
3) Generics
4) Collection API
5) I/O
Important topics/features in Java 8
1) The most useful new parts of Java 8
2) Lambda expressions
To make instances of anonymous classes easier to write and read!
Introduction to the <<Lambda expressions >>
The lambda syntax
Functional interfaces.
Method references
Construction references.
A simple example
Interface :
public interface FileFilter {
boolean accept(File file);
}
Implementation class :
public class JavaFileFilter implements FileFilter {
public boolean accept(File file) {
return file.getName().endsWith(".java");
}
}
Use it as :
JavaFileFilter fileFilter = new JavaFileFilter();
File dir = new file("d:/tmp");
File[] javaFiles = dir.listFiles(fileFilter);
Also let's use an anonymous class :
FileFilter fileFilter = new FileFilter() {
@Override
public boolean accept (File file) {
return file.getName().endsWith(".java");
}
};
File dir = new File("d:/tmp");
File[] javaFiles = dir.listFiles(fileFilter);
Let's write above code in Lambda expressions :
FileFilter filter =(File file) -> file.getName().endsWith(".java");
3) The Stream API and Collectors.
4) And many bits and pieces.
5) Java FX
6) Nashorn
New script engine.
No comments:
Post a Comment