What is Java String Class?



Strings, which are widely used in Java programming, are a sequence of characters. In Java programming language, strings are treated as objects. The Java platform provides the String class to create and manipulate strings. The most direct way to create a string is to write −

String greeting = "Hello world!";

Example

public class StringDemo {
   public static void main(String args[]) {
      char[] helloArray = { 'h', 'e', 'l', 'l', 'o', '.' };
      String helloString = new String(helloArray);
      System.out.println( helloString );
   }
}


Output

hello.

Advertisements