Concept
#1. Functional interface only contains the declaration of an abstract method. All types of Lambda expressions will match this abstract method.
Usage Notes
2. As long as the interface only contains one abstract method, we can rewrite it as a Lambda expression. In order to ensure that the interface is clearly defined as a functional interface (Functional Interface), we need to add annotation: @FunctionalInterface to the interface. This way, the compiler will throw an error as soon as you add the second abstract method.
Example
@FunctionalInterface interface Converter<F, T> { T convert(F from); }
1. Simple. As long as you understand the basic concepts, you can write programs suitable for various situations. Application;
2. Object-oriented;
3. Distribution, Java is a network-oriented language;
4. Robustness, java provides automatic garbage collection To carry out memory management and prevent programmers from making mistakes when managing memory;
5. Security, Java used in network and distributed environments must prevent virus intrusion;
6 , Architecture neutral, as long as the Java runtime system is installed, it can run on any processor;
7. Portability, Java can be easily transplanted to different machines on the network;
8. Interpretation and execution. The Java interpreter directly interprets and executes Java bytecode.
The above is the detailed content of What issues to pay attention to: Things to note when using Java functional interfaces. For more information, please follow other related articles on the PHP Chinese website!