• int[] data = new int[26];
    • In Java, arrays are objects, and when you create an array, memory is allocated for it.
    • The JVM (Java Virtual Machine) initializes all elements of the array to their default values:
      • For int, the default value is 0.
      • For boolean, the default value is false.
      • For object types (e.g., String, Integer), the default value is null.
  • Object Class Obviously Object is superclass of all class whether you write extends or not one of the method is .toString() which returns
    • The class name of the object.
    • The @ symbol.
    • The unsigned hexadecimal representation of the object’s hash code.
    • For example: ClassName@hashCode (e.g., MyClass@1b6d3586).
    • To get something meaningful we usually override this method as per our
    • Data type wrapper class already overrides it
@Override
public String toString() {
    return "Person{name='" + name + "', age=" + age + "}";
}
  • this or name - to clarify current instance as there could be more with same name in the scope
  • While playing with String either use .charAt(i) or just convert it to character array toCharArray() -> One major thing is Arrays has sort method which can be used
  • Use String Builder for mutable String for efficiency use append, reverse methods and stuff
  • Arrays.fill(arr,value) to initialize array with some value
  • In int[] we can create a new array by using Arrays.copyOfRange(arr,start,end)
  • In java local variable needs to be initialized but instance and static variable in class and array are initialized by default
  • Character has isLetter isDigit or isLetterOrDigit
  • StringBuilder s = new StringBuilder() we can then use append
  • Use List.of(a,b,c) to create list
  • substring(begIndex, endIndex) inclusive start index and exclusive end index
  • The trim() method removes whitespace from both ends of a string.
  • Checked vs Unchecked exception checked when written at class level using throws then you need to throw that otherwise it is compiler error which is not true for unchecked although both the exception will happen at runtime only
  • Java is pass-by-value, even for objects — but when you pass an array, you’re passing the reference to the array object by value.
  • Synchronized means thread safe and if something is thread safe then it takes time as compared to someone who doesn’t care about these things
  • Collections.reverse() for reversing list
  • sublist(start,end) for sub list end in excluded
  • Parent parent = new child then new allocates memory which has both parent and child and a parent is referencing it so ideally it has access to child methods but java does not allow it to use it and only allows overridden methods of child to be accessed