user3535778
user3535778

Reputation: 135

Lambda Expressions Cannot find symbol

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

Upvotes: 0

Views: 2513

Answers (1)

assylias
assylias

Reputation: 328913

Your syntax is wrong;

Interface f = () -> System.out.println("test");

Upvotes: 4

Related Questions