Java #4: Solution