package com.shine;
public class Entry {
public static void main(String[] args) {
int a, b;
a = 100;
b = 100;
if(a == b) {
System.out.println("ture");
}
int aa = new Integer(100);
int bb = new Integer(100);
if(aa == bb) {
System.out.println("aa = bb");
}
else {
System.out.println("aa != bb");
}
Integer cc = new Integer(100);
Integer dd = new Integer(100);
if(cc == dd) {
System.out.println("cc = dd");
}
else {
System.out.println("cc != dd"); //Integer类修饰的是字符串,相当于cc的地址与dd的地址不等
}
boolean res = cc.equals(dd); //对于字符串的比较必须用equals
System.out.println(res);
//字符串比较一定要用equals不要用==
String strA = new String("hello");
String strB = new String("hello");
if(strA.equals(strB)) {
System.out.println("strA = strB");
}
else {
System.out.println("strA != strB");
}
}
}
public class Entry {
public static void main(String[] args) {
int a, b;
a = 100;
b = 100;
if(a == b) {
System.out.println("ture");
}
int aa = new Integer(100);
int bb = new Integer(100);
if(aa == bb) {
System.out.println("aa = bb");
}
else {
System.out.println("aa != bb");
}
Integer cc = new Integer(100);
Integer dd = new Integer(100);
if(cc == dd) {
System.out.println("cc = dd");
}
else {
System.out.println("cc != dd"); //Integer类修饰的是字符串,相当于cc的地址与dd的地址不等
}
boolean res = cc.equals(dd); //对于字符串的比较必须用equals
System.out.println(res);
//字符串比较一定要用equals不要用==
String strA = new String("hello");
String strB = new String("hello");
if(strA.equals(strB)) {
System.out.println("strA = strB");
}
else {
System.out.println("strA != strB");
}
}
}