관리 메뉴

moozi

String 변수에 저장된 참조값(Hashcode) 출력하기 본문

자바

String 변수에 저장된 참조값(Hashcode) 출력하기

moozi 2017. 6. 28. 17:42

String 변수에 저장된 참조값(Hashcode) 출력하기

 

  String s1="Hello";
  String s2="Hello";
  
  System.out.println(s1);
  System.out.println(s2);
  
  System.out.println(Integer.toHexString(System.identityHashCode(s1)));
  System.out.println(Integer.toHexString(System.identityHashCode(s2)));
  
  s2="abcd";
  
  System.out.println(s1);
  System.out.println(s2);
  
  System.out.println(Integer.toHexString(System.identityHashCode(s1)));
  System.out.println(Integer.toHexString(System.identityHashCode(s2)));
  
  String s3=new String("zzz");
  String s4=new String("zzz");
  
  System.out.println(s3);
  System.out.println(s4);
  
  System.out.println(Integer.toHexString(System.identityHashCode(s3)));
  System.out.println(Integer.toHexString(System.identityHashCode(s4)));
  

'자바' 카테고리의 다른 글

JSP Gmail smtp 사용하기  (0) 2017.11.02
JSP 트랜잭션  (0) 2017.10.25
jar실행시 cmd창 바로 종료하는 배치파일 만들기  (0) 2017.01.02
스윙 5.6 컴보2B  (0) 2015.05.06
Swing 2  (0) 2015.04.30
Comments