What is String Class Java?
In Java, the String
class represents a sequence of characters and is used to create and manipulate strings. It is part of the java.lang
package and is immutable, meaning once a String
object is created, it cannot be altered. Common methods include length()
, charAt(int index)
, substring(int start, int end)
, and equals(Object obj)
. Strings can be created using string literals or by using the new String()
constructor. The String
class also supports concatenation, comparison, and various utility methods for string manipulation.