JAVA Basic 강의자료] hashCode()

 

JAVA Basic 강의자료] hashCode()

 

 

 

실무개발자를위한 실무교육 전문교육센터학원
www.oraclejava.co.kr에 오시면 보다 다양한 강좌를 보실 수 있습니다.

 

 

 

hashCode()

 

 

* hashCode()의 기능과 사용 예제
  - hashCode()
    = hash code value를 int형으로 반환
    = public native int hashCode()
    = hash code value : 객체가 가지는 유일한 참조값
    = 객체의 메모리를 비교할 때 사용

 

<소스코드>

 

import java.util.*;

public class HashCodeTest{
     public static void main(String[] args) {
          System.out.println(“new Date() : ” + new Date().hashCode());
          System.out.println(“new Object() : ” + new Object().hashCode());
          System.out.println(“new Date() : ” + new Date().hashCode());
          System.out.println(“new Object() : ” + new Object().hashCode());
     }
}

+ Recent posts