Java 8 method reference to static void method

vach

Is there a way to refer static method that returns void?

i've tried this

public Function<Runnable, Void> runner = Platform::runLater;

but it will say "bad return type, cannot convert void to java.lang.Void"

Eran

If your method has no return value, don't use the Function interface.

Use Consumer<Runnable> instead.

public Consumer<Runnable> runner = Platform::runLater;

It represents an operation that accepts a single input argument and returns no result.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Java 8 - how do I declare a method reference to an unbound non-static method that returns void

From Dev

java 8 method reference calling non static method in a static way

From Java

Java 8: method reference to a static method in a non-static way

From Dev

Java 8 - Static Method Reference Rule

From Java

Java 8 reference to a static method vs. instance method

From Java

Method reference in Java 8

From Dev

Calling a static void Java method from JNI

From Dev

Java8: Why the reference method don't compile when the referenced method isn't static?

From Dev

Method reference for FileFilter Java 8

From Java

Java 8: Reference to [method] is ambiguous

From Dev

Java 8 Comparator with Method reference

From Java

Java 8 chained method reference?

From Dev

java 8 method reference into lambda

From Dev

Reference Assignment in void method

From Dev

Java local static method reference shorthand syntax

From Java

java8: method reference from another method reference

From Dev

Java 8 Optional.ofNullable.map producing Non static method reference error

From Dev

method reference for instance method from static method

From Dev

JAVA - Cannot make a static reference to the non-static method

From Dev

How to make a static reference to a non-static method in Java?

From Dev

Java: Cannot Make Static Reference to Non Static Method error

From Dev

Java 8 type inference static method call

From Dev

Limits of static method references in Java 8

From Dev

Storing static void method as function

From Dev

JUnit test a static void method

From Dev

Call a method in the Static void main

From Java

How to get the MethodInfo of a Java 8 method reference?

From Java

Invoking toString via method reference in Java 8

From Dev

Type of method reference and lambda in Java 8

Related Related

  1. 1

    Java 8 - how do I declare a method reference to an unbound non-static method that returns void

  2. 2

    java 8 method reference calling non static method in a static way

  3. 3

    Java 8: method reference to a static method in a non-static way

  4. 4

    Java 8 - Static Method Reference Rule

  5. 5

    Java 8 reference to a static method vs. instance method

  6. 6

    Method reference in Java 8

  7. 7

    Calling a static void Java method from JNI

  8. 8

    Java8: Why the reference method don't compile when the referenced method isn't static?

  9. 9

    Method reference for FileFilter Java 8

  10. 10

    Java 8: Reference to [method] is ambiguous

  11. 11

    Java 8 Comparator with Method reference

  12. 12

    Java 8 chained method reference?

  13. 13

    java 8 method reference into lambda

  14. 14

    Reference Assignment in void method

  15. 15

    Java local static method reference shorthand syntax

  16. 16

    java8: method reference from another method reference

  17. 17

    Java 8 Optional.ofNullable.map producing Non static method reference error

  18. 18

    method reference for instance method from static method

  19. 19

    JAVA - Cannot make a static reference to the non-static method

  20. 20

    How to make a static reference to a non-static method in Java?

  21. 21

    Java: Cannot Make Static Reference to Non Static Method error

  22. 22

    Java 8 type inference static method call

  23. 23

    Limits of static method references in Java 8

  24. 24

    Storing static void method as function

  25. 25

    JUnit test a static void method

  26. 26

    Call a method in the Static void main

  27. 27

    How to get the MethodInfo of a Java 8 method reference?

  28. 28

    Invoking toString via method reference in Java 8

  29. 29

    Type of method reference and lambda in Java 8

HotTag

Archive