30) String
String is a sequence of characters, for e.g. “Hello” is a string of 5 characters. In java, string is an immutable object which means it is constant and can cannot be changed once it has been created.
Java String class is defined in java.lang
package.
Ways to Create a String Object:
Method 1: Using "new" keyword
Execute below:
Method 2: Using "+" operator
Execute below:
Method 3: Using char[ ] array and passing it to overloaded String constructor.
Execute below:
Last updated