Helpful functions to use in Java