我正在爲人員開發一個班級,我對此有一個或兩個問題。如何解決此警告?
/**
* ADT for persons which is completed which subclasses
* to creating actors with specific properties
*/
public class Person {
/**
* Name of the Person.
*/
public String name;
/**
* The World which this Person is associated with.
*/
public World world;
/**
* Tells where this Person is at the moment.
*/
public Place where;
/**
* The inventory, contains Things.
*/
public Collection<Thing> inventory;
/**
* Shows how the Person looks like
*/
public Image appearance;
/**
* Create Person named `name' in world `world'.
*
* @param world The world where the Person is created.
* @param name Name of the Person.
* @param app An image used to display the Person.
*/
public Person(World world, String name, Image app) {
this.world = world;
this.name = name;
this.appearance = app;
where = world.defaultPlace();
where.enter(this);
inventory = Collections.synchronizedCollection(new LinkedList());
}
...
如果Person類是公共的,或者可以默認訪問是更好嗎?一個人,私人人應該是公衆是不是有點奇怪,即使這裏的含義不完全相同。
當我的IDE對
inventory = Collections.synchronizedCollection(new LinkedList());
發出警告時,應如何處理該arning?它警告我的類型安全。
謝謝