我想使用 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/数据类型/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 的可变类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!