Solutions implemented in Java