Java 程序中的静态代码块
静态代码块:
1、用来给静态变量赋初始值;
2、只执行一次;
public class LevelParam { public final static Level[] levels = new Level[6]; static { levels[0] = new Level(1, 2, 10, 30, 1); // 每一级的规则 levels[1] = new Level(2, 3, 9, 26, 2); levels[2] = new Level(3, 4, 8, 22, 5); levels[3] = new Level(4, 5, 7, 18, 8); } }