“Code too large” compilation error in Java

后端 未结 13 1232
半阙折子戏
半阙折子戏 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:49

    I have run into this problem myself. The solution that worked for me was to refactor and shrink the method to more manageable pieces. Like you, I am dealing with a nearly 10K line method. However, with the use of static variables as well as smaller modular functions, the problem was resolved.

    Seems there would be a better workaround, but using Java 8, there is none...

提交回复
热议问题