Вопрос

Nothing seems weird here: 2Classes. Interface.java and Lambdas.java

public class Lambdas {
  public static void main(String[] args) {
    new Lambdas().start();
  }

  public void start(){
    Interface f = () -> Interface{System.out.println("test");}
  }
}

public interface Interface {
     void test();
}

I get error: Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - cannot find symbol symbol: variable Interface location: class lambdas.Lambdas . I don't know why.

P.S. Just arrived home from Java Day 2014 , I use their examples - with netbeans

Это было полезно?

Решение

Your syntax is wrong;

Interface f = () -> System.out.println("test");
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top