How does method reference casting work?
public class Main { interface Capitalizer { public String capitalize(String name); } public String toUpperCase() { return "ALLCAPS"; } public static void main(String[] args) { Capitalizer c = String::toUpperCase; //This works c = Main::toUpperCase; //Compile error } } Both are instance methods with same signature. Why does one work and the other doesn't? Signature of String::toUpperCase : String toUpperCase(); gniewkos There are 3 constructs to reference a method: object::instanceMethod Class::staticMethod Class::instanceMethod The line: Capitalizer c = String::toUpperCase; //This works use 3