String()
설명
Constructs an instance of the String class. There are multiple versions that construct Strings from different data types (i.e. format them as sequences of characters), including:
- a constant string of characters, in double quotes (i.e. a char array)
- a single constant character, in single quotes
- another instance of the String object
- a constant integer or long integer
- a constant integer or long integer, using a specified base
- an integer or long integer variable
- an integer or long integer variable, using a specified base
- a float or double, using a specified decimal places
Constructing a String from a number results in a string that contains the ASCII representation of that number:
- The default is base ten, so: String thisString = String(13); gives you the String "13".
- However, you can use other bases. For example: String thisString = String(13, HEX); gives you the String "D", which is the hexadecimal representation of the decimal value 13.
- Or if you prefer binary, String thisString = String(13, BIN); gives you the String "1101", which is the binary representation of 13.
문법
매개변수
- val: a variable to format as a String - 허용되는 자료형: string, char, byte, int, long, unsigned int, unsigned long, float, double
- base (optional): the base in which to format an integral value
- decimalPlaces (val 이 float 또는 double): the desired decimal places
반환값
- an instance of the String class.
예제 코드
All of the following are valid declarations for Strings.
함수
- 언어 : String.charAt()
- 언어 : String.compareTo()
- 언어 : String.concat()
- 언어 : String.c_str()
- 언어 : String.endsWith()
- 언어 : String.equals()
- 언어 : String.getBytes()
- 언어 : String.indexOf()
- 언어 : String.lastIndexOf()
- 언어 : String.length()
- 언어 : String.remove()
- 언어 : String.replace()
- 언어 : String.reserve()
- 언어 : String.setCharAt()
- 언어 : String.startsWith()
- 언어 : String.substring()
- 언어 : String.toCharArray()
- 언어 : String.toInt()
- 언어 : String.toFloat()
- 언어 : String.toLowerCase()
- 언어 : String.toUpperCase()
- 언어 : String.trim()
연산자
- 언어 : [\] (element access)
- 언어 : + (concatenation)
- 언어 : += (append)
- 언어 : == (comparison)
- 언어 : > (greater than)
- 언어 : < (less than)
- 언어 : != (different from)
- 튜토리얼 : Built-in String Tutorials
더보기
- 언어 : 배열
- 언어 : boolean
- 언어 : byte
- 언어 : char
- 언어 : double
- 언어 : float
- 언어 : int
- 언어 : long
- 언어 : short
- 언어 : string
- 언어 : unsigned char
- 언어 : unsigned int
- 언어 : unsigned long
- 언어 : void
- 언어 : word
※ ARDUINO BUY RECOMMENDATION
Arduino UNO R3 | |
Arduino Starter Kit |
Additionally, some links direct to products from our own brand, DIYables.