What is String in Java?
Java String is a sequence of characters.
Java String variable contains a collection of characters surrounded by double quotes.
An array of characters works same as Java String.
Java Strings are used for storing text.
In Java, Strings are immutable or final or constant which means each time when we are creating or editing or performing any method to change string, one string created in "String Constant Pool"
How to create a String in Java?
There are two ways to create a String object:
- By string literal
- By new keyword