added java solution for problem b