Lambda表示式
import org.springframework.beans.factory.ObjectFactory; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class InterfaceMain { private static final Map<String, ObjectFactory<?>> map = new ConcurrentHashMap<>(); User addDate(){ System.out.println("ceshi"); return new User(); } void test(){ map.put("1",()->addDate()); } public static void main(String[] args) { new InterfaceMain().test(); System.out.println(map.get("1").getObject()); } }