Java String Notes
Java String Notes
2. Stored in String Pool: String literals are stored in a special memory area called the String
Constant Pool.
lexicographically.
5. Supports Unicode: Java Strings support Unicode, allowing a wide range of characters.
- int length()
2. Comparison
3. Searching
- boolean contains(CharSequence s)
5. Case Conversion
- String toLowerCase()
- String toUpperCase()
- String trim()
- String strip()
- String stripLeading()
- String stripTrailing()
- char[] toCharArray()
- byte[] getBytes()
11. Interning
- String intern()
- boolean isEmpty()
- boolean isBlank()
Example:
System.out.println(s.length()); // 13
System.out.println(s.contains("World")); // true
System.out.println(s.charAt(1)); // 'H'
- s: Original string.
Example:
s = s.replaceFirst(part, "");