(java) Solved problem 22
(java) Solved problem 23