AtomicInteger
클래스에는 다음 정의를 갖는 get()
및 intValue()
의 두 가지 메소드가 있습니다.AtomicInteger의 get() vs 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 메소드를 사용할 수 있습니다. 그러한 연습에 이점이 있는지 설명하십시오.
'get' 대신에'intValue()'를 볼 때 코드가 읽기 쉽습니다. – xenteros
'intValue()'메소드는'java.lang.Integer' 클래스와의 통일성을 위해 존재할 것입니다. – Jesper
'intValue()'메소드는'AtomicInteger'가'Number'를 확장하기 때문에 존재합니다. – EJP