Basic java algorithims