package 测试常量;
public class Test {
public static void main(String[] args){
String s1 = “hello world”;
String s2 = “hello world”;
System.out.println(s1==s2);
String s4 = new String(“你好”);
String s3 = “你好”;
System.out.println(s3==s4);
Integer i1 = 10;
Integer i2 = 10;
System.out.println(i1 == i2);
Integer i3 = 2000;
Integer i4 = 2000;
System.out.println(i3 == i4);
Integer i5 = new Integer(10);
Integer i6 = new Integer(10);
System.out.println(i5 == i6);
int i7 = 2000;
int i8 = 2000;
System.out.println(i7 == i8);
Double f1 = new Double(1.01);
Double f2 = new Double(1.01);
System.out.println(f1 == f2);
Double f3 = 1000.01;
Double f4 = 1000.01;
System.out.println(f3 == f4);
double f5 = 1000.01;
double f6 = 1000.01;
System.out.println(f5 == f6);
}
}
输出结果是
true
false
true
false
false
true
false
false
true