Arduino> Variables> Data Types> String Operators>
[]
[StringObject Operator]
Description
Allows you access to the individual characters of a String.
Syntax
char thisChar = myString1[n]
Parameters
thisChar
: Allowed data types: char.myString1
: Allowed data types: String.n
: a numeric variable.Returns
The nth char of the String. Same as charAt().
+
[StringObject Operator]
Description
Combines, or concatenates two Strings into one new String. The second String is appended to the first, and the result is placed in a new String. Works the same as string.concat().
Syntax
myString3 = myString1 + myString2
Parameters
myString1
: a String variable.myString2
: a String variable.myString3
: a String variable.Returns
New String that is the combination of the original two Strings.
-------------------------------------------------------------------
+=
[StringObject Operator]
Description
It concatenates Strings with other data.
Syntax
myString1 += data
Parameters
myString1
: a String variable.Returns
Nothing
==
[StringObject Operator]
Description
Compares two Strings for equality. The comparison is case-sensitive, meaning the String "hello" is not equal to the String "HELLO". Functionally the same as string.equals()
Syntax
myString1 == myString2
Parameters
myString1
: a String variable.myString2
: a String variable.Returns
true
: if myString1 equals myString2.false
: otherwise.
-------------------------------------------------------------------
>
[StringObject Operator]
Description
Tests if the String on the left is greater than the String on the right. This operator evaluates Strings in alphabetical order, on the first character where the two differ. So, for example "b" > "a" and "2" > "1", but "999" > "1000" because 9 comes after 1.
Caution: String comparison operators can be confusing when you’re comparing numeric Strings, because the numbers are treated as Strings and not as numbers. If you need to compare numbers numerically, compare them as ints, floats, or longs, and not as Strings.
Caution: String comparison operators can be confusing when you’re comparing numeric Strings, because the numbers are treated as Strings and not as numbers. If you need to compare numbers numerically, compare them as ints, floats, or longs, and not as Strings.
Syntax
myString1 > myString2
Parameters
myString1
: a String variable.myString2
: a String variable.Returns
true
: if myString1 equals myString2.false
: otherwise.>=
[StringObject Operator]
Description
Tests if the String on the left is greater than, or equal to, the String on the right. This operator evaluate Strings in alphabetical order, on the first character where the two differ. So, for example "b" >= "a" and "2" >= "1", but "999" >= "1000" because 9 comes after 1.
Caution: String comparison operators can be confusing when you’re comparing numeric Strings, because the numbers are treated as Strings and not as numbers. If you need to compare numbers numerically, compare them as ints, floats, or longs, and not as Strings.
Caution: String comparison operators can be confusing when you’re comparing numeric Strings, because the numbers are treated as Strings and not as numbers. If you need to compare numbers numerically, compare them as ints, floats, or longs, and not as Strings.
Syntax
myString1 >= myString2
Parameters
myString1
: variable of type String.`myString2
: variable of type String.Returns
true
: if myString1 is greater than or equal to myString2.false
: otherwise.
-------------------------------------------------------------------
<
[StringObject Operator]
Description
Tests if the String on the left is less than the String on the right. This operator 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 the numbers are treated as Strings and not as numbers. If you need to compare numbers numerically, compare them as ints, floats, or longs, and not as Strings.
Caution: String comparison operators can be confusing when you’re comparing numeric Strings, because the numbers are treated as Strings and not as numbers. If you need to compare numbers numerically, compare them as ints, floats, or longs, and not as Strings.
Syntax
myString1 < myString2
Parameters
myString1
: variable of type String.`myString2
: variable of type String.Returns
true
: if myString1 is less than myString2.false
: otherwise.<=
[StringObject Operator]
Description
Tests if the String on the left is less than or equal to the String on the right. This operator 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 the numbers are treated as Strings and not as numbers. If you need to compare numbers numerically, compare them as ints, floats, or longs, and not as Strings.
Caution: String comparison operators can be confusing when you’re comparing numeric Strings, because the numbers are treated as Strings and not as numbers. If you need to compare numbers numerically, compare them as ints, floats, or longs, and not as Strings.
Syntax
myString1 <= myString2
Parameters
myString1
: variable of type String.myString2
: variable of type String.Returns
true
: if myString1 is less than or equal to myString2.false
: otherwise.
-------------------------------------------------------------------
!=
[StringObject Operator]
Description
Compares two Strings for difference. The comparison is case-sensitive, meaning the String "hello" is not equal to the String "HELLO". Functionally the same as string.equals()
Syntax
myString1 != myString2
Parameters
myString1
: a String variable.`myString2
: a String variable.Returns
true
: if myString1 is different from myString2.false
: otherwise.
Post a Comment
Hi Users, if you have any queries then please let me know.