Can you use a method reference to define a class implementing a Functional interface in java 8

93 views Asked by At

So we know that Java 8 method references can be used to replace anonymous class creation. I'm curious if there's a way to use them to define named classes that implement a functional interface, something -- vaguely -- along the lines of

   public interface Bar {
       String returnSomeString();
   }

   public class Foo implements Bar = someObjectInstance::toString;

I know you can't use equals in defining a class, but something like that...

0

There are 0 answers