Behavior of Functional Interface and Method Reference
问题 What happens when the reference of a method which belongs to a variable is destroyed? public class Hey{ public double bar; public Hey(){ bar = 2.0d; } public double square(double num){ return Math.pow(num , bar); } } Function<Double, Double> square; whatsGonnaHappen: { Hey hey = new Hey(); square = hey::square; }//is hey still kept around because its method is being referenced? double ans = square.apply(23d); 回答1: Scope is a compile time concept that governs where names in source code can be