juan_gandhi: (Default)
Juan-Carlos Gandhi ([personal profile] juan_gandhi) wrote2008-04-28 03:35 pm

Java bashing


enum Color {
  RED(0xff0000),
  GREEN(0x00ff00),
  BLUE(0x0000ff),
  WHITE(0xffffff);
  int code; 

  Color(int code) {
    this.code = code;
  }

  public int getCode() {
    return code;
  }
}

//... (many files away)
Set<Color> myPalette = newHashSet(RED, WHITE, BLUE);

//... (many lines/files away)
if (myPalette.contains(0xff0000)) {
  System.out.println("0xff0000 is our color!");
}

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting