Large amount of constants in Java

Posted by Lars D on Stack Overflow See other posts from Stack Overflow or by Lars D
Published on 2010-05-04T07:04:27Z Indexed on 2010/05/04 7:08 UTC
Read the original article Hit count: 169

Filed under:

I need to include about 1 MByte of data in a Java application, for very fast and easy access in the rest of the source code. My main background is not Java, so my initial idea was to convert the data directly to Java source code, defining 1MByte of constant arrays, classes (instead of C++ struct) etc., something like this:

public final/immutable/const MyClass MyList[] = { 
  { 23012, 22, "Hamburger"} , 
  { 28375, 123, "Kieler"}
};

However, it seems that Java does not support such constructs. Is this correct? If yes, what is the best solution to this problem?

© Stack Overflow or respective owner

Related posts about java