헉!!/jsp, java
[java] JAVA 1.7의 Integer.compare를 1.6에서 실행할때
권태성
2013. 12. 10. 13:46
JAVA 1.7에서 작성한 소스를 1.6에서 빌드를 하려고 하면 일부 메소드들이 지원되지 않아 오류가 납니다.
아래 예제는 그 중 Integer.compare 메소드의 경우 입니다.
compare
public static int compare(int x, int y)
Compares twoint
values numerically. The value returned is identical to what would be returned by:Integer.valueOf(x).compareTo(Integer.valueOf(y))
- Parameters:
x
- the firstint
to comparey
- the secondint
to compare- Returns:
- the value
0
ifx == y
; a value less than0
ifx < y
; and a value greater than0
ifx > y
- Since:
- 1.7
위 문서는 JAVA API 1.7에 있는 compare 메소드에 관한 내용 입니다. 보시다시피 1.7에 추가된것을 확인하실 수 있습니다.
(API 출처 : http://docs.oracle.com/javase/7/docs/api/index.html)
간단하게 1.7 이하 버전에서 사용시에는 위 내용에 있듯이 Integer.valueOf(x).compareTo(Integer.valueOf(y)) 형태로 사용하시면 됩니다.
728x90