Why doesn't Integer.parseInt(“1”)++ work in Java?

后端 未结 5 558
渐次进展
渐次进展 2020-12-30 00:26

I\'ve got the following line of code:

suffix = suffix.isEmpty() ? \"1\" : Integer.toString(Integer.parseInt(suffix)+1);

in a block where su

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-30 01:28

    Writing i++ is a shortcut for i=i+1; if you were to 'read it in english' you'd read it as "i becomes current value of i plus one"

    which is why 3++ doesn't make sense you can't really say 3 = 3+1 (read as 3 becomes current value of 3 plus one) :-)

提交回复
热议问题