Java Code:
1 2 3 4 5 6 7 8 9 10 11 | public class Main { public static void main(String args[]) { char[] javacode = { 'J', 'A', 'V', 'A', 'C', 'O', 'D', 'E' }; String helloString = new String(javacode); System.out.println(helloString); } } |
Output:
1 2 3 | JAVACODE |
String is a sequence of characters.
Java String provides a lot of concepts that can be performed on a string such as compare, concat, equals, split, length, replace, compareTo, intern, substring etc.
Syntax : String greeting = “Welcome to Code4Example!”;
The java.lang.String class implements Serializable, Comparable and CharSequence interfaces.
The java String is immutable i.e. it cannot be changed but a new instance is created. For mutable class, you can use StringBuffer and StringBuilder class.