我有一些舊的代碼,我想升級到仿製藥:重新編碼原始類型,以仿製藥
/**
* Places in this World
*/
public Map places;
/**
* Players watching this World
*/
public Collection players;
/**
* A reference to the Adventure using this World
*/
public Adventure owner;
/**
* Create a World. `a' is a reference to the Frame itself.
* This reference is used when loading images and sounds.
*
* @param a An instance of adventure.
*/
public World(Adventure a) {
places = new HashMap();
players = new LinkedList();
owner = a;
}
我的IDE警告我說,我沒有參數化的變量places
和players
所以我應該泛型添加到這個代碼但是如何?當我將<>
或<Place>
添加到「位置」對象時,它表示它不是泛型,但是我做它會導致錯誤。你能告訴我如何將這部分代碼現代化爲使用泛型?
感謝
很好,它的工作原理。我不必更改冒險宣言,並按照您現在正在使用的其他對象的建議而不發出警告。謝謝! –