“Code too large” compilation error in Java

后端 未结 13 1454
半阙折子戏
半阙折子戏 2020-11-22 14:33

Is there any maximum size for code in Java? I wrote a function with more than 10,000 lines. Actually, each line assigns a value to an array variable.

arts_b         


        
13条回答
  •  不要未来只要你来
    2020-11-22 14:51

    A single method in a Java class may be at most 64KB of bytecode.

    But you should clean this up!

    Use .properties file to store this data, and load it via java.util.Properties

    You can do this by placing the .properties file on your classpath, and use:

    Properties properties = new Properties();
    InputStream inputStream = getClass().getResourceAsStream("yourfile.properties");
    properties.load(inputStream);
    

提交回复
热议问题