Add Java solution to problem 1