equals 与==
1、equals 与==
import java.util.*;
public class _02_32{
public static void main(String[] args){
String s1="bc";
if(s1=="bc")
System.out.println("s1==bc");
else
System.out.println("s1!=bc");
if(s1.equals("bc"))
System.out.println("s1 equals bc");
else
System.out.println("s1 不equals bc");
}
}
结果:
s1==bc
s1 equals bc