这个问题在这里已有答案:
我收到一个错误,上面写着“重复的类:(包名)。(类名)”这是代码,说错误的行是“公共类敌人”
package rpgdemo;
public class Enemy {
String name;
int weaponId;
int baseAtk;
int baseDef;
int hitRate;
int hp;
public Enemy(String name,int weaponId, int baseAtk,int baseDef,int hitRate,int hp){
this.name = name;
this.weaponId = weaponId;
this.hp = hp;
this.baseAtk = baseAtk;
this.baseDef = baseDef;
this.hitRate = hitRate;
}
}
问题是你有另一个包含相同类名的类。也许您之前删除了java文件,但类文件仍然存在。所以我建议你清理并构建项目。
如果包中没有相同的类,请尝试清除编辑器的缓存,否则更改类名。检查这个java - duplicate class