Increment a Integer's int value?

前端 未结 9 2087
你的背包
你的背包 2020-12-14 05:11

How do I increment a Integer\'s value in Java? I know I can get the value with intValue, and I can set it with new Integer(int i).

playerID.intValue()++;
         


        
9条回答
  •  失恋的感觉
    2020-12-14 06:04

    For Java 7, increment operator '++' works on Integers. Below is a tested example

        Integer i = new Integer( 12 );
        System.out.println(i); //12
        i = i++;
        System.out.println(i); //13
    

提交回复
热议问题