What is Java String Class?

Java 8Object Oriented ProgrammingProgramming

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.
raja
Published on 09-Feb-2018 15:11:49
Advertisements