java.lang.Enum>

时间:2022-02-26 19:47:19

public enum Direction {
  L, LU, U, RU, R, RD, D, LD, STOP, JUMP;
}

for(Direction d: Direction.values()) {
  this.drawPaoTong(g, d);
}

for (int i = 0; i < Direction.values().length; i++) {
  Direction.values()[i];
}

枚举随机遍历:Direction.values()[new Random().nextInt(Direction.values().length)];