以下代码在
第1行
处出现编译错误,错误信息如下:
我的问题是为什么会出现这个错误,因为我已经在构造函数中初始化了该字段。空白final字段可能未被初始化
public class Test1 {
private final String name;
public Test1() {
name = "abc";
}
@SuppressWarnings("rawtypes")
private final Function fs = n -> {
System.out.println(this.name);// Line 1
return n;
};
public static void main(String[] args) {
new Test1();
}
}