java8新特性构造器引用问题
public class Employee {int id;
String name;
int age;
double salary;
public Employee() {
}
public Employee(int id) {
this.id = id;
}
public Employee(int id, String name, int age, double salary) {
this.id = id;
this.name = name;
this.age = age;
this.salary = salary;
}
}
@Test
public void test1(){
Supplier<Employee> sup1 = () -> new Employee();
System.out.println(sup1.get());
System.out.println("****************************");
Supplier<Employee> sup2 = Employee::new;
System.out.println(sup2.get());
}
调试结果是:
com.nuist.java2.Employee@649d209a
****************************
com.nuist.java2.Employee@357246de
为什么不是:
Employee{id=0,name='null',age=0,salary=0.0}
请问是哪里出问题了?急急急