关于JAVA代码 求教

publicvoidaddEntity(Entityentity){//Preconditions;entitynotnullassert(entity!=null);/... public void addEntity(Entity entity)
{
// Preconditions; entity not null

assert(entity!=null);

// Method proper

removeEntity(entity.getEntityID());

entityMap.put(entity.getEntityID(), entity);
entityVector.add(entity);

if(entity instanceof Drawable) drawableVector.add(entity);
if(entity instanceof UserInfo) userInfoVector.add(entity);
if(entity instanceof Claim) claimVector.add(entity);
if(entity instanceof ChatState) chatStateVector.add(entity);
}
解释下 谢谢了
展开
 我来答
jg...7@163.com
2011-04-20 · TA获得超过287个赞
知道小有建树答主
回答量:149
采纳率:0%
帮助的人:189万
展开全部
以下是我加的注释,希望对你有帮助。
public void addEntity(Entity entity)
{
// Preconditions; entity not null

assert(entity!=null); //当entity!=null为true时,程序继续执行,否则抛出java.lang.AssertionError,程序终止

// Method proper

removeEntity(entity.getEntityID()); //移除指定实体id的entity对象

entityMap.put(entity.getEntityID(), entity); //在entityMap集合中加入以实体id为主键,以对象entity为值的键值对
entityVector.add(entity); //将entity写入entityVector集合中

if(entity instanceof Drawable) drawableVector.add(entity); //如果对象entity是类Drawable的实例,则将此对象加入drawableVector集合中
if(entity instanceof UserInfo) userInfoVector.add(entity);//如果对象entity是类UserInfo的实例,则将此对象加入userInfoVector集合中
if(entity instanceof Claim) claimVector.add(entity);//如果对象entity是类Claim的实例,则将此对象加入claimVector集合中
if(entity instanceof ChatState) chatStateVector.add(entity);//如果对象entity是类ChatState的实例,则将此对象加入chatStateVector集合中
}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式