仅当字段赋值位于实例或 static 初始值设定项中时报告,并且将其与字段声明联接可能比较安全。 在其他情况下(比如构造函数中的赋值),提供的快速修复不会高亮显示,因为修正可能会更改语义。
示例:
class MyClass {
static final int intConstant;
static {
intConstant = 10;
}
}
该快速修复会将赋予的值移至字段初始值设定项,并移除类初始值设定项(如果可能):
class MyClass {
static final int intConstant = 10;
}
自从 2017.2