for loop terminating early when comparing to Integer.MAX_VALUE and using System.out.println

前端 未结 2 1070
梦如初夏
梦如初夏 2021-01-12 03:34

When I run this class the for loop seems to terminate early

class Test {

    public static void main(String[] args) {
        int result = 0;
        int en         


        
2条回答
  •  一向
    一向 (楼主)
    2021-01-12 04:00

    You can work around the JVM bug by using Integer.MAX_VALUE-1.

提交回复
热议问题