我有一些想要升级到泛型的遗留代码:
/**
* 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
所以我应该在这段代码中添加泛型,但是如何?当我向“places”对象添加<>
或<Place>
时,它说它不是泛型,所以我这样做结果是错误的。你能告诉我如何将这部分代码现代化为使用泛型吗?
谢谢