solve 3.6, Java