javalangString
javalangString is not an official Java API term, but is sometimes used informally to refer to the string data type in Java, as implemented by the class java.lang.String. In this sense, javalangString denotes the immutable sequence of Unicode code units used to represent text in Java applications.
Java strings are instances of the final class java.lang.String. They are immutable, meaning that once created,
Key methods and behavior include:
- length(), charAt(int), substring(int, int)
- equals(Object), compareTo(String), equalsIgnoreCase(String)
- startsWith(String), endsWith(String), contains(CharSequence)
- indexOf(String), lastIndexOf(String), trim(), replace(CharSequence, CharSequence)
- toLowerCase(), toUpperCase(), split(String)
- valueOf(Object), copyValueOf(char[]), intern()
Interning plays a role in memory efficiency: string literals are typically pooled, and intern() can be used
Common considerations: Java favors immutability for safety and thread-safety. Repeated string concatenation in loops is inefficient;