It’s not possible. As per the error message Object
is not a functional interface, that is an interface with a single public method so you need to use a reference type that is, e.g.
Runnable r = () -> {};
More Related Contents:
- How will Java lambda functions be compiled?
- Why is String.chars() a stream of ints in Java 8?
- Using Java 8’s Optional with Stream::flatMap
- Remove duplicates from a list of objects based on property in Java 8 [duplicate]
- Java 8’s streams: why parallel stream is slower?
- Difference between year-of-era and week-based-year?
- Unit testing a class with a Java 8 Clock
- Optional orElse Optional in Java
- Transform Java Future into a CompletableFuture
- What does “an Arbitrary Object of a Particular Type” mean in java 8?
- JavaFX on Linux is showing a “Graphics Device initialization failed for : es2, sw”
- How do I create a Stream of regex matches?
- How to get Method Parameter names in Java 8 using reflection?
- How to calculate the number of days in a period?
- Error:java: javacTask: source release 8 requires target release 1.8
- Why use Optional.of over Optional.ofNullable?
- How to extract epoch from LocalDate and LocalDateTime?
- Java 8 Lambda Expression Within REST Service not working
- Java 8 timezone conversions
- Can a java lambda have more than 1 parameter?
- Get original pattern String given a JDK 8 DateTimeFormatter?
- Are defaults in JDK 8 a form of multiple inheritance in Java?
- What’s the purpose of partitioningBy
- Using method reference instead of multi argument lambda
- Spring + AspectJ weaving for java 8 using aspectj-maven-plugin
- Visualization of Java Stream parallelization
- Why does a Java Lambda which throws a Runtime Exception require brackets?
- Consumer mapped Class in HashMap
- Get last element of Stream/List in a one-liner
- Java 8 Supplier Exception handling with CompletableFuture