Try using
Iterator<String>
instead of Iterator This happens because the Iterator interface is generified. And BTW its not an error but just a warning. hope this helps
Hi, I've slightly modified your code and it should get compiled with no warnings:
public class BeerSelect extends HttpServlet{
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
String c = request.getParameter("color");
BeerExpert be = new BeerExpert();
List<String> result = be.getBrands(c);
ServletContext sc = this.getServletConfig().getServletContext();
request.setAttribute("styles",result);
RequestDispatcher view = sc.getRequestDispatcher("result.jsp");
view.forward(request,response);
}
}
I think the only way to get such a warning here is from BeerExpert class, if for example it returns List and not List like this:
public class BeerExpert {
public List getBrands(String color) {
return new ArrayList(); // really dumb implementation, you should have something smarter here
}
}
I suggest you to check this out and if needed to change to :
public class BeerExpert {
public List<String> getBrands(String color) {
return new ArrayList<String>();
}
}
Hope this helps