Java String Class Methods
Java Strings
Immutable sequences of characters with rich method library.
String Operations
String str = "Hello World";
int len = str.length(); // 11
String sub = str.substring(0,5); // "Hello"
boolean eq = str.equals("hello"); // false
String upper = str.toUpperCase(); // "HELLO WORLD"Key Points
- Strings are immutable (new objects created).
StringBuilderfor mutable strings.- String pool for memory efficiency.
- Common methods:
charAt(), indexOf(), replace(), trim().