Sre*_*hat 0 java oop integer atomicinteger
AtomicIntegerclass有2个方法,get()并intValue()有以下定义.
intValue() 定义:
/**
* Returns the value of this {@code AtomicInteger} as an {@code int}.
*/
public int intValue() {
return get();
}
Run Code Online (Sandbox Code Playgroud)
get() 定义:
/**
* Gets the current value.
*
* @return the current value
*/
public final int get() {
return value;
}
Run Code Online (Sandbox Code Playgroud)
有一个非最终方法intValue()有什么好处?出于所有实际目的,如果我没有错,我们可以使用get方法.请解释这种做法是否有任何好处.