关于ADSL宽带多重拨号的探究
2012-09-22 09:26
211 查看
java 代码
public class HashCodeTest {
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {}
@Test
public void testHashCode(){
String a = new String("AA");
String b = a;
String c = new String("AA");
String d = new String("BB");
String e = "AA";
String f = "AA";
System.out.println("String a hashcode is : "+ a.hashCode());
System.out.println("String b hashcode is : "+ b.hashCode());
System.out.println("String c hashcode is : "+ c.hashCode());
System.out.println("String d hashcode is : "+ d.hashCode());
System.out.println("String e hashcode is : "+ e.hashCode());
System.out.println("String f hashcode is : "+ f.hashCode());
System.out.println("a.equals(b) : "+ a.equals(b));
System.out.println("a==b : "+ (a==b));
System.out.println("a.equals(c) : "+ a.equals(c));
System.out.println("a==c : "+ (a==c));
System.out.println("b.equals(c) : "+ b.equals(c));
System.out.println("b==c : "+ (b==c));
System.out.println("a.equals(e) : "+ a.equals(e));
System.out.println("a==e : "+ (a==e));
System.out.println("e.equals(f) : "+ e.equals(f));
System.out.println("e==f : "+ (e==f));
Person p1 = new Person();
Person p2 = p1;
Person p3 = new Person();
System.out.println("Model p1 hashcode is : "+ p1.hashCode());
System.out.println("Model p2 hashcode is : "+ p2.hashCode());
System.out.println("Model p3 hashcode is : "+ p3.hashCode());
System.out.println("p1.equals(p2) : "+ p1.equals(p2));
System.out.println("p1==p2 : "+ (p1==p2));
System.out.println("p1.equals(p3) : "+ p1.equals(p3));
System.out.println("p1==p3 : "+ (p1==p3));
System.out.println("p2.equals(p3) : "+ p2.equals(p3));
System.out.println("p2==p3 : "+ (p2==p3));
}
}
打印的结果为:
java 代码
String a hashcode is : 2080
String b hashcode is : 2080
String c hashcode is : 2080
String d hashcode is : 2112
String e hashcode is : 2080
String f hashcode is : 2080
a.equals(b) : true
a==b : true
a.equals(c) : true
a==c : false
b.equals(c) : true
b==c : false
a.equals(e) : true
a==e : false
e.equals(f) : true
e==f : true
Model p1 hashcode is : 12934710
Model p2 hashcode is : 12934710
Model p3 hashcode is : 28064776
p1.equals(p2) : true
p1==p2 : true
p1.equals(p3) : false
p1==p3 : false
p2.equals(p3) : false
p2==p3 : false
结论:
待续。。。
public class HashCodeTest {
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {}
@Test
public void testHashCode(){
String a = new String("AA");
String b = a;
String c = new String("AA");
String d = new String("BB");
String e = "AA";
String f = "AA";
System.out.println("String a hashcode is : "+ a.hashCode());
System.out.println("String b hashcode is : "+ b.hashCode());
System.out.println("String c hashcode is : "+ c.hashCode());
System.out.println("String d hashcode is : "+ d.hashCode());
System.out.println("String e hashcode is : "+ e.hashCode());
System.out.println("String f hashcode is : "+ f.hashCode());
System.out.println("a.equals(b) : "+ a.equals(b));
System.out.println("a==b : "+ (a==b));
System.out.println("a.equals(c) : "+ a.equals(c));
System.out.println("a==c : "+ (a==c));
System.out.println("b.equals(c) : "+ b.equals(c));
System.out.println("b==c : "+ (b==c));
System.out.println("a.equals(e) : "+ a.equals(e));
System.out.println("a==e : "+ (a==e));
System.out.println("e.equals(f) : "+ e.equals(f));
System.out.println("e==f : "+ (e==f));
Person p1 = new Person();
Person p2 = p1;
Person p3 = new Person();
System.out.println("Model p1 hashcode is : "+ p1.hashCode());
System.out.println("Model p2 hashcode is : "+ p2.hashCode());
System.out.println("Model p3 hashcode is : "+ p3.hashCode());
System.out.println("p1.equals(p2) : "+ p1.equals(p2));
System.out.println("p1==p2 : "+ (p1==p2));
System.out.println("p1.equals(p3) : "+ p1.equals(p3));
System.out.println("p1==p3 : "+ (p1==p3));
System.out.println("p2.equals(p3) : "+ p2.equals(p3));
System.out.println("p2==p3 : "+ (p2==p3));
}
}
打印的结果为:
java 代码
String a hashcode is : 2080
String b hashcode is : 2080
String c hashcode is : 2080
String d hashcode is : 2112
String e hashcode is : 2080
String f hashcode is : 2080
a.equals(b) : true
a==b : true
a.equals(c) : true
a==c : false
b.equals(c) : true
b==c : false
a.equals(e) : true
a==e : false
e.equals(f) : true
e==f : true
Model p1 hashcode is : 12934710
Model p2 hashcode is : 12934710
Model p3 hashcode is : 28064776
p1.equals(p2) : true
p1==p2 : true
p1.equals(p3) : false
p1==p3 : false
p2.equals(p3) : false
p2==p3 : false
结论:
待续。。。
相关文章推荐
- 关于adsl宽带猫的一个奇怪问题
- 关于ADSL(PPPOE)拨号上网图标双击无效的问题
- ADSL宽带拨号的常见故障解决方案
- 关于宽带拨号上网的笑话,我自己闹的笑话。
- ADSL宽带拨号的经典解决方案
- ADSL宽带拨号691错误代码分析与详细解释
- ADSL宽带拨号错误代码大全及原因分析
- 教你如何让电脑的ADSL宽带连接开机自动拨号
- 关于获取宽带拨号密码
- 映射篇(5.2) 02. ADSL拨号宽带映射 ❀ 飞塔 (Fortinet) 防火墙
- ADSL宽带拨号密码的另类拿法
- 关于ADSL 拨号频繁掉线
- 关于ADSL的自动拨号 断号 来实现更换IP的实现
- RAS ADSL Dial 宽带 拨号
- 关于win8宽带拨号问题!!!
- 关于从list或者数组中随机抽取部分不重复元素的问题探究
- 关于ExtJs5的初步探究一
- Win8系统下宽带拨号连接在哪如何找到宽带拨号连接
- 如何在redhat下宽带拨号上网