[understood]
because static blocks and static members are of the same level, the program executes in sequence
topic description
Why can you use the numeric object nums,bombs,flags of the Image class that should not have been initialized in the static block?
sources of topics and their own ideas
Source: https://github.com/fgksgf/Min.
related codes
class Block {
//
private int x;
private int y;
//
boolean flip = false;
//
boolean over = false;
// , 012
int flag = 0;
// :0-89
int category = 0;
private static Image nums[] = new Image[9];
private static Image bombs[] = new Image[2];
private static Image flags[] = new Image[3];
static {
try {
//
for (int i = 0; i < 9; iPP) {
nums[i] = ImageIO.read(new File("images/" + i + ".jpg"));
}
for (int i = 0; i < 2; iPP) {
//
bombs[i] = ImageIO.read(new File("images/bomb" + i + ".jpg"));
}
for (int i = 0; i < 3; iPP) {
//
flags[i] = ImageIO.read(new File("images/flag" + i + ".jpg"));
}
} catch (IOException e) {
e.printStackTrace();
}
}
what result do you expect? What is the error message actually seen?
did I misunderstand it in the first place?