package com;
import java.util.Date;
public class test {
public static void main(String[] args) {
Integer integer1 = new Integer(1);
Integer integer2 = new Integer(1);
String str1 = new String("123");
String str2 = new String("123");
Date date1 = new Date();
Date date2 = new Date();
Double double1 = new Double("1.0");
Double double2 = new Double("1.0");
Boolean tem1 = new Boolean(true);
Boolean tem2 = new Boolean(true);
Object object1 = new Object();
Object object2 = new Object();
System.out.println("----Object------");
System.out.println(object1.equals(object2));
System.out.println(object1 == object2);
System.out.println(object1.equals(object1));
System.out.println(object1 == object1);
System.out.println("----Boolean------");
System.out.println(tem1.equals(tem2));
System.out.println(tem1 == tem2);
System.out.println("----Double------");
System.out.println(double1.equals(double2));
System.out.println(double1 == double2);
System.out.println("----Integer------");
System.out.println(integer1.equals(integer2));
System.out.println(integer1 == integer2);
System.out.println("----String------");
System.out.println(str1.equals(str2));
System.out.println(str1 == str2);
System.out.println("----Date------");
System.out.println(date1.equals(date2));
System.out.println(date1 == date2);
}
}
public boolean equals(Object obj) {
return (this == obj);
}
public boolean equals(Object obj) {
if (obj instanceof Boolean) {
return value == ((Boolean)obj).booleanValue();
}
return false;
}
public boolean equals(Object obj) {
return (obj instanceof Double)
&& (doubleToLongBits(((Double)obj).value) ==
doubleToLongBits(value));
}
public boolean equals(Object obj) {
if (obj instanceof Integer) {
return value == ((Integer)obj).intValue();
}
return false;
}
public boolean equals(Object anObject) {
if (this == anObject) {
return true;
}
if (anObject instanceof String) {
String anotherString = (String) anObject;
int n = value.length;
if (n == anotherString.value.length) {
char v1[] = value;
char v2[] = anotherString.value;
int i = 0;
while (n-- != 0) {
if (v1[i] != v2[i])
return false;
i++;
}
return true;
}
}
return false;
}
public boolean equals(Object obj) {
return obj instanceof Date && getTime() == ((Date) obj).getTime();
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-3 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2026 源码网商城 (www.yuanmawang.com) 版权所有