기본 콘텐츠로 건너뛰기

5월, 2018의 게시물 표시

Integer - java

최대 최소값 최소 -2의 31승 / 최대 2의 31승-1 @Native public static final int MIN_VALUE = 0x80000000 ; @Native public static final int MAX_VALUE = 0x7fffffff ; toString() - 10진수를 다른진법으로, 문자열로 변환 Integer . toString ( 10 ) // 10 Integer . toString ( 10 , 2 ) // 1010 Integer . toString ( 10 , 5 ) // 20 toBinaryString(), toOctalString, toHexString() 자주사용하는 2진수, 8진수, 16진수는 별도함수가 있다. Integer . toBinaryString ( num ) // 1010 Integer . toOctalString ( num ) // 12 Integer . toHexString ( num ) // a valueOf() IntegerCache 사용(-128~127) cache범위가 벗어날때는 새로운 Integer객체를 생성 public static Integer valueOf ( int i ) { if ( i >= IntegerCache . low && i <= IntegerCache . high ) return IntegerCache . cache [ i + ( - IntegerCache . low ) ] ; return new Integer ( i ) ; } equals() 타입이 Integer인지, 값이 같은지 public boolean equals ( Object obj ) { if ( obj instanceof Integer ) { return value == ( (