Hide minor edits - Show changes to markup
(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/8.Strings/StringComparisonOperators/StringComparisonOperators.ino lang=arduino tabwidth=4:)
(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/08.Strings/StringComparisonOperators/StringComparisonOperators.ino lang=arduino tabwidth=4:)
(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/8.Strings/StringComparisonOperators/StringComparisonOperators.pde lang=arduino tabwidth=4:)
(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/8.Strings/StringComparisonOperators/StringComparisonOperators.ino lang=arduino tabwidth=4:)
(:div class=BOM :)
No external hardware is required. (:divend:)
(:div class=BOM :)
(:divend:)
There is no circuit for this example.
There is no circuit for this example, though your Arduino must be connected to your computer via USB.
image developed using Fritzing. For more circuit examples, see the Fritzing project page
(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/8.Strings/StringComparisonOperators/StringComparisonOperators.pde lang=arduino tabwidth=4:)
(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/8.Strings/StringComparisonOperators/StringComparisonOperators.pde lang=arduino tabwidth=4:)
if (stringOne.equals(stringTwo)) {
(:source lang=arduino tabwidth=4:)
if (stringOne.equals(stringTwo)) {
(:sourceend:)
if (stringOne ==stringTwo) {
(:source lang=arduino tabwidth=4:)
if (stringOne ==stringTwo) {
(:sourceend:)
The greater than and less than operators evaluate strings in alphabetical order, on the first character where the two differ. So, for example "a" < "b" and "1" < "2", but @@"999"> "1000" because 9 comes after 1.
The greater than and less than operators evaluate strings in alphabetical order, on the first character where the two differ. So, for example "a" < "b" and "1" < "2", but "999"> "1000" because 9 comes after 1.
The operator == and the function @@equals() perform identically. It's just a matter of which you prefer. So
The operator == and the function equals() perform identically. It's just a matter of which you prefer. So
Examples > Strings
The String comparison operators, ==, !=,>, < ,>=, <= , and the functionsequals() and equalsIgoreCase() allow you to make alphabetic comparisons between Strings. They're useful for sorting and alphabetizing, among other things.
(:div class=BOM :)
No external hardware is required. (:divend:)
The operator == and the function @@equals() perform identically. It's just a matter of which you prefer. So
(:div class=code :)
if (stringOne.equals(stringTwo)) {
is identical to
if (stringOne ==stringTwo) {
(:divend:)
The greater than and less than operators evaluate strings in alphabetical order, on the first character where the two differ. So, for example "a" < "b" and "1" < "2", but @@"999"> "1000" because 9 comes after 1.
Caution: String comparison operators can be confusing when you're comparing numeric strings, because you're used to thinking of them as numbers, not strings. If you have to compare numbers, compare them as ints, floats, or longs, and not as Strings.
(:div class=circuit :) There is no circuit for this example. (:divend:)
(:div class=code :)
(:source