I am trying to understand this example code from Oracle Learning on Lambdas and Method References:
String city = "Munich";
Supplier<String> lambda = city::toUpperCase;
System.out.println(lambda.get());
Why didn't they simply call
city.toUpperCase();
Isn't this method tied to the specific instance variable city
?
So how would it execute in a different context to provide the benefits of lambdas - I am unable to understand that.