José Soler
José Soler

Reputation: 63

Java Invalid Assignment Operator

I'm trying to use the method references of Java 8. However, Eclipse says I'm using an invalid assignment operator instead of accepting the reference. I do not realize what my mistake is. Thanks!

public static void printAlumnes(Curs curs)
{
    String string = alumnesLlista.values().stream()

    .filter(alumne -> alumne.getCurs().equals(curs))
    .map(Alumne::toString())
    .sorted()
    .collect(Collectors.joining(" ; "));

Upvotes: 0

Views: 667

Answers (1)

Michael
Michael

Reputation: 44090

Alumne::toString() is not valid syntax for a method reference. It should be Alumne::toString (i.e. no parentheses)

Upvotes: 5

Related Questions