Java是否具有Integer,Float,Double,Long的可变类型? [英] Does Java have mutable types for Integer, Float, Double, Long?

查看:630
本文介绍了Java是否具有Integer,Float,Double,Long的可变类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我处在一种情况,我想使用像Integer这样的可变版本。我是否必须使用这些类(下面)或者Java内置了什么?

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://www.java2s.com/Code/Java/Data-Type/Amutableintwrapper.htm

推荐答案

不,Java没有这些内置。这是有原因的。使用可变类型很危险,因为它们很容易被滥用。此外,它实现起来非常容易。例如,commons-lang有一个 MutableInt

No, Java doesn't have these built in. And that is for a reason. Using mutable types is dangerous, as they can easily be misused. Additionally, it is really easy to implement it. For example, commons-lang has a MutableInt.

这篇关于Java是否具有Integer,Float,Double,Long的可变类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆