AtomicInteger
类有 2 个方法,get()
并intValue()
具有以下定义。
intValue()
定义 :
/**
* Returns the value of this {@code AtomicInteger} as an {@code int}.
*/
public int intValue() {
return get();
}
get()
定义:
/**
* Gets the current value.
*
* @return the current value
*/
public final int get() {
return value;
}
使用非最终方法 intValue() 有什么好处吗?出于所有实际目的,如果我没有错,我们可以使用 get 方法。请解释这种做法是否有任何好处。