Java #6: Solution