String methods that return String

  • substring(i1, i2) or substring(i1) which returns the substring from i1 to i2 (or end of String is omitted).
  • toLowerCase
  • toUpperCase
  • stripLeading und stripTailing remove spaces at the beginning (resp. end) of the String.

String methods that return int

  • length() returns the number of characters in the string
  • `indexOf()

String methods that return boolean

String comparisons

Do not compare strings with == in Java as this compares their references and not the actual string value. Use .equals() for this.

References

Simple types are passed by value, not reference. This means that passing an int or long into a function and changing it there will not change it’s value in the calling function.

This is not true for Lists however, as they are complex types. Passing int[] a into a function and changing the value of an index, will change that value also in the calling function.

If you however replace the memory address a points to, by overwriting it with a = b for example, this will not change what the calling function sees as a. Thus you need to copy over all elements from b into a if you need to change it.