public class Test4 { public static void main(String[] args) { // TODO Auto-generated method stub String s0 = 'I Love Java.'; String s1 = new String(s0); String s2 = new String(s0); String s3 = 'I Love Java.'; String s4 = 'I Love Java.'; System.out.printf("\t%b", s1 == s2); System.out.printf("\t%b", s1.equals(s2)); System.out.printf("\t%b", s3 == s4); System.out.printf("\t%b", s3.equals(s4)); } }

程序的运行结果是 ( )

false true false true

Java 字符串比较:== 和 equals() 方法

原文地址: https://www.cveoy.top/t/topic/oofP 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录