String - Java
- Basic
- Immutable => Unmodifiable or Unchangeable
- ClassLoader
- Thread Safe
- Security
- Heap Space
- Methods to Create
- String Constant Pool => Using
"",Duplicate value is not created
- Heap => Using
new keyword
- Commands
String varS = new String("abc12") => Initialize a new String
String varS = varS1 + varS2 => Concatenate/Join 2 or more Strings to create a new String
varS.length() => Returns the length of the String
varS.charAt(N) => Returns the Character preset at the given Index
varS.replace('S1', 'S2') => Replaces 'S1' in the given String by 'S2' and Returns the new String without changing the old String
varS.substring(N1, N2) => Creates a String from "n1" index to "n2" and Returns it, "n2" is not included
varS.equals("abc") => Returns true if both are equal
varS.isEmpty() => Returns true if String is empty
varS.toLowerCase()
varS.indexOf(āCā)
varS.strip()
varS.stripLeading()
varS. stripTrailing()
varS.isBlank ()
varS.repeat(N)
String varS = String.valueOf(varS1); => Converts Character Array into String
String varS = String.copyValueOf(varS1); => Converts Character Array into String
String varS = String.copyValueOf(varS1, N1, N2); => Convert Character Array from n1 to n2 into String
String varS = toString(varS1); => Converts Character Array into String