Index
 
  The Wiring 1.0 _ALPHA_ Reference is a work in progress.
If you see any errors or have any comments, please write to: hbarragan [at] uniandes.edu.co
Name  

String

   
Examples  
String a = "CCCP"; 
char data[] = {'C', 'C', 'C', 'P'}; 
String b = String(data); 
 
Serial.println(a);  // Prints 'CCCP' to the Serial serial port 
Serial.println(b);  // Prints 'CCCP' to the Serial serial port 


char t[] = "A character string"; 
String a = String("hello");  
String b = String(" there"); 
String c = String(t); 
 
a += b; // a holds now 'hello there' equivalent to a.append(b) 
Serial.println(c);  // Prints 'A character string' to the Serial serial port 

Description   A string is a sequence of characters. The class String includes methods for examining individual characters, comparing strings, searching strings, extracting parts of strings, and for converting an entire string uppercase and lowercase. Strings are always defined inside double quotes ("Abc") and characters are always defined inside single quotes('A').

Note that the Wiring String class has differences with the processing or Java String class. The main difference is that some methods modify the actual string instead of returning a modified copy of it.
   
Methods  
charAt()
  Returns the character at the specified index

append()
  Appends the String representation of the argument specified

capacity()
  Returns the internal capacity of the String

contains()
  Returns true if there is an occurrence of the input string

getBytes()
  Returns an array of bytes containing the characters of the String as bytes

setCharAt()
  Changes the character specified at the specified index

endsWith()
  Returns true if the current string ends with the input string

equals()
  Compares a string to a specified object

indexOf()
  Returns the index value of the first occurrence of a character within the input string

length()
  Returns the number of characters in the input string

replace()
  Replaces all the occurrences of a character in a string with the specified character

startsWith()
  Returns true if the current string starts with the input string

substring()
  Returns a new string that is part of the input string

toCharArray()
  Returns the content of the specified String as an array of chars

toLowerCase()
  Converts all the characters to lower case

toUpperCase()
  Converts all the characters to upper case

   
   
Constructors  
String(data)
   
Parameters  
data   byte[], char[]: array of bytes to be decoded into characters or array of characters to be combined into a string, int: empty string with the specified initial capacity, String: string to be copied into the created string

   
Usage   Web & Application
   
Related   char