File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
src/main/java/io/javaalmanac/snippets/language Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,11 @@ static void classMethod() {
33
33
System .out .println ("classMethod" );
34
34
}
35
35
36
+ static int classMethodWithReturn (String parameter ) {
37
+ System .out .println ("classMethodWithReturn " + parameter );
38
+ return 42 ;
39
+ }
40
+
36
41
}
37
42
38
43
public static void main (String [] args ) {
@@ -57,6 +62,11 @@ public static void main(String[] args) {
57
62
Runnable runnable2 = Foo ::classMethod ;
58
63
runnable2 .run ();
59
64
65
+ // Method return values are ignored if the functional interface method
66
+ // has return type void
67
+ Consumer <String > consumer2 = Foo ::classMethodWithReturn ;
68
+ consumer2 .accept ("hello" );
69
+
60
70
// Array constructor as reference
61
71
IntFunction <Foo []> function = Foo []::new ;
62
72
Foo [] array = function .apply (42 );
You can’t perform that action at this time.
0 commit comments