String a = "Hello\u200e";
String b = "Hello\u200f";
System.out.println("a = '" + a + "' and b = '" + b + "' are length "
+ a.length() + " and " + b.length()
+ ", equals() is " + a.equals(b));
上述代碼片段中的代碼產生以下輸出。Java字符串中的隱形字符
一個=「你好」和b =「你好」是長度6,6,等於()爲假
雖然在控制檯上顯示的兩個a
和b
的值是Hello
,a.equals(b)
返回false
。怎麼樣?