ArrayList display = new ArrayList();
for (Player p : game.getAllPlayers())
display.add(new StringBuilder().append(game.isPlayerActive(p) ? ChatColor.BLACK : ChatColor.GRAY).append(NameUtil.stylize(p.getName(), true, !game.isPlayerActive(p))).toString()); int no;
int line;
try {
no = 2;
line = 0;
for (String s : display) {
((Sign)this.signs.get(no)).setLine(line, s);
line++;
if (line >= 4) {
line = 0;
no++;
}
}
} catch (Exception e) { }
for (Sign s : this.signs)
s.update();
有人能帮帮我吗?当我写“for(String s:display){”它给我一个DISPLAY错误
答案 0 :(得分:1)
更改
ArrayList display = new ArrayList();
到
ArrayList<String> display = new ArrayList<String>();
但作为最佳实践,left元素必须是一个接口,因此最好设置:
List<String> display = new ArrayList<String>();
或者,甚至更好
Collection<String> display = new ArrayList<String>();