solve 4.4, Java