我来到这个问题是因为我正在尝试解决一个类似的问题。出于性能原因,我想将具有1600个元素的图形硬编码到2D整数数组中。我正在解决一个类似于Leetcode网站的问题,并且从文件加载图形数据不是一个选项。整个图形超过了64K的最大限制,因此我不能进行单个静态运行的分配。我将分配跨越几个静态方法,每个方法都在限制以下,然后逐个调用每个方法。
private static int[][] G = new int[1601][];
static {
assignFirst250();
assignSecond250();
assignSecond500();
assignThird500();
}
private static void assignFirst250() {
G[1] = new int[]{3,8,15,24,35,48,63,80,99,120,143,168,195,224,255,288,323,360,399,440,483,528,575,624,675,728,783,840,899,960,1023,1088,1155,1224,1295,1368,1443,1520,1599};
G[2] = new int[]{2,7,14,23,34,47,62,79,98,119,142,167,194,223,254,287,322,359,398,439,482,527,574,623,674,727,782,839,898,959,1022,1087,1154,1223,1294,1367,1442,1519,1598};