Solving popular problem solving problems using Java