例:
class Item {
// 再利用可能な長さがゼロの public 配列定数
public static final Item[] EMPTY_ARRAY = new Item[0];
}
class EmptyNode {
Item[] getChildren() {
// 長さがゼロの配列の作成は不要
return new Item[0];
}
}
クイックフィックス適用後:
class EmptyNode {
Item[] getChildren() {
return Item.EMPTY_ARRAY;
}
}