简体   繁体   中英

Large 2D double array in Java

I try to initialize 2D double array in java, this double array has 1000 rows and 50 cols.

when I did that I got this error:

 Too many constants, the constant pool for ClassName would exceed to 65536 entries.

The following is part of my work:

   double[][] haltonArray = {{0.116538, -1.08275, -0.832512, 1.9746, 1.68741, 2.23391, 
          0.703111, -0.400975, -1.8214, -2.22141, 0.127014, -1.31939, 
          0.874426, 0.0916673, 0.236509, 0.731912, 1.43766, 0.88484, 
          1.13653, -0.882871, -0.212072, -0.431315, -1.21639, -0.0352919, 
          0.334481, 0.891777, -0.178983, 0.531624, -0.360295, 0.551329, 
          0.696159, -0.595714, 0.27043, -0.262656, -0.176079, -0.667502, 
          0.66105, -0.593195, 2.10675, 
          0.168339, -0.918746, -1.59296, -0.0584028, -0.336773, -1.0043, 
        -1.59346, -0.041084, 1.93094, 0.896973,0.637633}, 
        {-0.534821, -0.0682488, -0.246726, -1.08433, -1.61264, 
        -1.47508, 0.907127, -0.261507, -1.42036, -1.66814, 0.209045,      -1.17226,
           0.967877, 0.150398, 0.291741, 0.795219, 1.56906, 0.947359, 
          1.21103, -0.831883, -0.177076, -0.396745, -1.15539, -0.00712026, 
          0.361938, 0.929345, -0.154306, 0.558805, -0.335862, 0.577341, 
          0.721534, -0.573016, 0.289458, -0.244034, -0.159018, -0.6469, 
          0.681047, -0.574957, 2.27073, 
          0.183053, -0.897595, -1.54553, -0.0452613, -0.323059, -0.983445, 
        -1.55014, -0.0291968, 2.00915, 0.913608, 0.651105}, {0.828784, ... }};

Any suggestion please?

The constant pool allows maximum of 65536 entries and hence you can not exceed the limit .

The constant pool table is where most of the literal constant values are stored. This includes values such as numbers of all sorts, strings, identifier names, references to classes and methods, and type descriptors. All indexes, or references, to specific constants in the constant pool table are given by 16-bit (type u2) numbers, where index value 1 refers to the first constant in the table (index value 0 is invalid).

Due to historic choices made during the file format development, the number of constants in the constant pool table is not actually the same as the constant pool count which precedes the table. First, the table is indexed starting at 1 (rather than 0), so the count should actually be interpreted as the maximum index. Additionally, two types of constants (longs and doubles) take up two consecutive slots in the table, although the second such slot is a phantom index that is never directly used.

The type of each item (constant) in the constant pool is identified by an initial byte tag. The number of bytes following this tag and their interpretation are then dependent upon the tag value.

For more details visit here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM