Article View: cn.bbs.comp.lang.java
Article #12457Re: ���ڴ�ֵ���Ǵ����õĽ�һ������
From: 98CS~��è~�����Կ�����
Date: Thu, 29 Jul 2004 03:27
Date: Thu, 29 Jul 2004 03:27
52 lines
3022 bytes
3022 bytes
�� �� nue.bbs@bbs.sjtu.edu.cn (NUE) �Ĵ������ᵽ: ��
: �� ��: Re: ���ڴ�ֵ���Ǵ����õĽ�һ������
: ����վ: ��ˮ˼Դ (Thu Jul 29 11:04:17 2004)
: ת��վ: NanKai!news2.happynet.org!netnews.sdu.edu.cn!SJTU
:
: As much as is reasonably practical, the hashCode method defined by class
: Object does return distinct integers for distinct objects. (This is
: typically implemented by converting the internal address of the object into
~~~~~~~~typically != always.
�����:
public class test{
public static void main( String[] args ){
String a = new String("Hello");
String b = new String("Hello");
System.out.println( a == b );
System.out.println( a.hashCode() );
System.out.println( b.hashCode() );
}
}
��Ϊa==b��false,����a��b������ͬһ�����������,
����a��b��hashCode()����ͬ��,������a��b��
��ַӦ���Dz�ͬ��.
: an integer, but this implementation technique is not required by the JavaTM
: programming language.)
:
: �� �� xeon.bbs@bbs.nankai.edu.cn (98CS~ ��è~������
: ������) �Ĵ������ᵽ: �� : ��������ڴ�����ַ������������object��hashCode.
: : ��Object��Ϊ��,toString()����ô�����:
: : public String toString()
: : {
: : return getClass().getName() + "@" + Integer.toHexString(hashCode());
: : }
: : �ٷ��ĵ�����hashCode()���������:
: : 1.Whenever it is invoked on the same object more than once during an execu
: : tion of a Java application, the hashCode method must consistently return
: : the same integer, provided no information used in equals comparisons on
: : .................������ʡ�ԣ�
: --
: [m[1;35m�� ��Դ:����ˮ˼Դ bbs.sjtu.edu.cn��[FROM: 219.206.224.14][m
--
���������ƣ� ����С��¯��
��������ѩ�� ����һ���ޡ�
[m[1;34m�� ��Դ:���Ұ��Ͽ�վ nkbbs.org��[FROM: 202.108.245.163][m
Technical Details
Message-ID:
<4DPZF0$9KH@bbs.nankai.edu.cn>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!news.moat.net!ctu-peer!news.nctu.edu.tw!netnews.csie.nctu.edu.tw!maily.cic.tsinghua.edu.cn!news2.happynet.org!NanKaiShow Full Headers
Complete Article Headers
X-Google-Thread: f6cb0,d356ce699e5f20c7 X-Google-Attributes: gidf6cb0,public X-Google-Language: Chinese,GB Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!news.moat.net!ctu-peer!news.nctu.edu.tw!netnews.csie.nctu.edu.tw!maily.cic.tsinghua.edu.cn!news2.happynet.org!NanKai From: xeon.bbs@bbs.nankai.edu.cn (98CS~��è~�����Կ�����) Newsgroups: cn.bbs.comp.lang.java Subject: Re: ���ڴ�ֵ���Ǵ����õĽ�һ������ Date: 29 Jul 2004 03:27:27 GMT Organization: �Ұ��Ͽ�վ Message-ID: <4DPZF0$9KH@bbs.nankai.edu.cn> X-Filename: Java/M.1091071440.A