Does Java have mutable types for Integer, Float, Double, Long?

前端 未结 7 1455
野趣味
野趣味 2020-12-01 15:48

I am in a situation where I want to use mutable versions of things like Integer. Do I have to use these classes (below) or does Java have something built in?

http://

相关标签:
7条回答
  • 2020-12-01 16:16

    You can use an nnnn[] as a mutable object for any primitive type as @Alexandre suggests, java also has AtomicInteger and AtomicLong.

    IMHO int is usually a better choice than Integer and that is mutable.

    Can you more details of why you need a mutliple object, perhaps there is another way to achieve the same thing.

    0 讨论(0)
提交回复
热议问题