solve 2.1, Java