0
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();

Can someone Help me??. when i write "for (String s : display) {" it gives me a DISPLAY error

1
  • You are using raw type ArrayList while you should be using parameterized type. Commented Nov 15, 2013 at 16:17

1 Answer 1

1

change

ArrayList display = new ArrayList();

to

ArrayList<String> display = new ArrayList<String>();

but as a best practice, left element must be an interface, so it is better to set:

List<String> display = new ArrayList<String>();

or, even better

Collection<String> display = new ArrayList<String>();
Sign up to request clarification or add additional context in comments.

1 Comment

I disagree with "must be an interface" and your assumptions about OP's usage. If you only need it as a Collection, then of course you can declare as such, but what if he/she needs random access and ordering? Just declare it as whatever is appropriate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.