equals()

描述

比較兩個字串是否相等。比較過程中會區分大小寫,所以字串 “hello” 和字串 “HELLO” 是不同的。

語法


string.equals(string2)

參數

string : String 物件 (字串)
string2 : 另一個 String 物件 (字串)

回傳

true: 假如 string 字串與 string2 字串相同
false: 與上面相反

範例

StringComparisonOperators

See also

String
equalsIgnoreCase()
compareTo()


語法參考主頁面

The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.