“Code too large” compilation error in Java

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

    ok maybe this answer is too late but I think this way is better than another way so

    for example, we have 1000 rows data in code

    1. break them

      private void rows500() {
           //you shoud write 1-500 rows here
      }
      
      private void rows1000() {
           you shoud write 500-1000 rows here
      }
      
    2. for better performance put an "if" in your codes

      if (count < 500) {
          rows500();
      } else if (count > 500) {
          rows1000();
      }
      

    I hope this code helps you

提交回复
热议问题