This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
    Bookmark Topic Watch Topic
  • New Topic

Xlint:unchecked

 
ahsan mir
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hello,
when i try to compile the following code as part of a servlet application , the following Xlint:unchecked error occurs.I cant understand since I am using jdk1.5 or is it referring to generics in collections?if so could anyone pls reply how to fix it(inc any code help).Thanks in advance.

****************************************************************************
import java.util.*;

public class BeerExpert{
public List getBrands(String color) {
List brands = new ArrayList();
if(color.equals("amber"))

{
brands.add("Jack Amber");
brands.add("Red Moose");
}
else
{
brands.add("Jail Pale Aile");
}
return (brands);
}

}

**************************************************************************
C:\javac BeerExpert.java
Note: BeerExpert.java uses unchecked or unsafe operations.
Note :Recompile with -Xlint:unchecked for details
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
If you're studying for SCWCD, you'd better use sdk1.4 instead.
That would spare you some time resolving that kind of problems.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Report post to moderator
This is a cross-post. Please continue this discussion in the Java in General (beginner) forum.
 
    Bookmark Topic Watch Topic
  • New Topic