String in Java

Strings are a data type in Java, which is not a primitive type. It is actually a Class.

Strings are a sequence of characters. and Strings can contain a sequence of characters.

public class String_Example {
    public static void main(String[] args) {

        String p = "This is unicode U0070: ";
        String unicode = "\u0070";
        System.out.println(p + unicode);
This is unicode U0070: p
  • Strings in Java are Immutable
    • You can not change a String after it is created. Instead, what happens is a new String is created.
    • As a result a Sting being created, appending values is inefficient and not recommended.

Leave a Reply

Your email address will not be published.