HW2 in Java