@ FunctionalInterface
Public interface ConInterface2 {
Void doSom (List d);
}
public class MainTest {
Public static void main (String [] args) {
ListA=new ArrayList ();
A.a dd (" aaa ");
A.a dd (" BBB ");
//a
ConInterface2 cif=(gg) - & gt; System. The out. Println (gg. Get (1));
Cif. DoSom (a);
//way.
Bb (a, q) (List - & gt; {
System. The out. Println (q.g et (1));
});
}
Private static void bb (List w, ConInterface2 c2) {
C2. DoSom (w);
}
}
The results
BBB
BBB
CodePudding user response:
Way is the lambda expressions assigned to the corresponding functional interface classWay 2 is the lambda expressions as a parameter to method directly to the
Although there is no use new, but every lamba expression will be the compiler to generate a new corresponding functional interface instance
CodePudding user response: