試圖實例化類時出現 - an enclosing instance that contains
的原因是什麼?無法創建類的實例
下面是我的實際代碼:
public static void main(String[] args) {
InterspecTradeItems_Type.Item_Type item = new InterspecTradeItems_Type.Item_Type();
// Error: an enclosing instance that contains InterspecTradeItems_Type.Item_Type is required
}
public class InterspecTradeItems_Type {
public class Item_Type {
}
}
感謝。
(HTTP [包含<我的參考>需要一個外圍實例]的可能重複:// stackoverflow.com/questions/4297857/an-enclosing-instance-that-contains-my-reference-is-required) –
如果您不需要Item_Type中的封閉類的實例,則應該將其設置爲靜態。 – NeplatnyUdaj