Declare and Set a String Variable

How to Declare and Set a String Variable

String was added in API Level 1

An immutable sequence of characters/code units (chars). A String is represented by array of UTF-16 values, such that Unicode supplementary characters (code points) are stored/encoded as surrogate pairs via Unicode code units (char).

1. Create an Android project, if you don't already have one.

2.In the MainActivity.java file, add the code below to the onCreate method. This creates a string named myString

      String myString = "My string contents are here";

3. Compile and run!

Related Articles:
Resources: