(java) Solved problem 43