Selfmade implementations of different functions from Java