如何在私有数组中存储下表中的十六进制颜色?
400 Bad Request - Invalid request body - JSON mapping failed.
颜色的名称存储在公共枚举中。数组也应该是class属性。
Name R G B
BLACK 00 00 00
NAVY 00 00 80
BLUE 00 00 FF
答案 0 :(得分:2)
您可以使用枚举为您存储值:
public enum COLORS {
BLACK(0x00, 0x00, 0x00),
NAVY(0x00, 0x00, 0x80),
BLUE(0x00, 0x00, 0xFF);
private int red;
private int green;
private int blue;
private COLORS(int red, int green, int blue) {
this.red = red;
this.green = green;
this.blue = blue;
}
public int getRed() {
return this.red;
}
public int getGreen() {
return this.green;
}
public int getBlue() {
return this.blue;
}
}