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.