Solving java problems