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

后端 未结 5 540
渐次进展
渐次进展 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:13

    ++ expects an assignable value, i.e. a variable. Integer.parseInt returns a value that cannot be assigned. If you need a value plus one, use Integer.parseInt(suffix)+1 instead.

提交回复
热议问题