我正在从.NET“转换”到Java。我想知道为什么下面的代码不起作用
class MyClass{
private final int intVar; //ok
private final Paint paint; //error "Variable paint might not have been initialized"
public MyClass(){
intVar = 12;
initializePaint();
}
private void initializePaint(){
paint = new Paint(); //error "cannot assign a variable to final variable"
}
}