Type safety warning
Im getting a warning that states
"Type safety: The method put(Object, Object) belongs to the raw type TreeMap.
References to generic type TreeMap<K,V> should be parameterized"
in the following code
public class....{
TreeMap entriesFlights =new TreeMap();
publicvoid addFlight(Flight aFlight){
String message;
//check if entry with the same name already exists
if(this.entriesFlights.keySet().contains(aFlight.getStartDest())){
message ="An entry with the name " + aFlight.getStartDest()+" already exists \n";
message = message + aFlight.getStartDest() +" has not been added";
reportError(message);
}
else{
this.entriesFlights.put(aFlight.getStartDest(),aFlight);//THIS IS THE LINE THAT IS UNDERLINED IN YELLOW (WARNING)
message ="Entry for " + aFlight.getStartDest();
message = message +" has been added to Airline Company";
confirmationMessage(message);
}
}
Im not sure what this type safety warning sign means.
My program runs fine without it (so far), but concerned that having programs with warning signs is bad practice.
[1748 byte] By [
B_Reala] at [2007-11-27 1:39:53]

So I guess you want something like:
TreeMap<String, Flight> entriesFlights = new TreeMap<String, Flight>();
Assuming GetDest returns a String.
The parameters are just telling everyone (developer and compiler) what type of objects are stored in the Map. This allows the compiler to check that you are not trying to put something else in there.
> Do I need to parameterize it then or can I leave it
> as it is?
>
You can leave it. The messages are just warnings, not errors, so they don't stop things from compiling or running. But yes, it is generally bad form to have warnings in your code. You can use an @ignore annotation or something like that to supress the warnings. It should be described in that generics page, or the pdf that's linked at the bottom of it.
> And what exactly is parameterization in laymans
> terms?
It's a way to specify a relationship among types at declaration time, and what exactly those types are at usage time. It lets you use the same code for different types, and have the compiler enforce that the usages of those types is consistent--for example, you don't put a String into a List and then try to get a Date out.