String 物件

描述

字串物件允许你使用比 字串阵列 更复杂的方式来操作字串。它可以连结字串、增加字串、搜寻字串、替换字串、等等…;相较于一般的字元阵列它会占用更多的记忆体空间,不过也更为有用。

仅供参考:以小写 s 开头的 string 字元阵列会被认为是字串,以大写 S 开头的 String 则是字串物件,注意字串常数会因为标记上双引号而被当作字元阵列,而不是字串物件。

函式

- String()
- charAt()
- compareTo()
- concat()
- endsWith()
- equals()
- equalsIgnoreCase()
- getBytes()
- indexOf()
- lastIndexOf()
- length()
- replace()
- reserve()
- setCharAt()
- startsWith()
- substring()
- toCharArray()
- toInt()
- toLowerCase()
- toUpperCase()
- trim()

运算子

- [] (element access)
- + (concatenation)
- == (comparison)

范例

下列 String 物件的范例来自 Arduino 教学网站,他们也可以在 86Duino 板上使用:

- StringConstructors
- StringAdditionOperator
- StringIndexOf
- StringAppendOperator
- StringLengthTrim
- StringCaseChanges
- StringReplace
- StringCharacters
- StringStartsWithEndsWith
- StringComparisonOperators
- StringSubstring

See also

- string: character arrays
- Variable Declaration


语法参考主页面

本页由热血青年 LBU 译自英文版。

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.