我正在为人员开发一个班级,我对此有一个或两个问题。如何解决此警告?
/**
* 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?它警告我的类型安全。
谢谢