【发布时间】:2016-03-16 18:10:43
【问题描述】:
我需要使用我在 if 语句中创建的变量。但是,我的代码无法编译。我只需要在编译它的同时保持功能不变的帮助。
这是代码片段
else if (in.equals("Monster") && in1.equals("Orc"))
{ Players Character = new Orc();
System.out.println("You have chosen "+in+" type "+in1+". Monsters in general are more attack orientated");
}
Character.addAttack(5);
【问题讨论】:
-
你只需要在你的 if 之外声明
Character。