Custom class extends HashMap - error: "Does not take parameters"
809141Oct 28 2010 — edited Nov 1 2010Hello all! This is my first forum post, and I chose this board because it seems to be the most active. I am fairly new to Java, but I'm already pretty deep into the language.
I have a custom class declared as follows:
public class DBFRecord extends HashMap {
// methods here, but no constructor
}
The idea was to get a custom HashMap class with a method for retrieving specifically typed values. My understanding is that, since I didn't include a constructor for the class, it defaults to the parent constructor, which is, of course, HashMap(). Where I ran into trouble was when I tried to fix a compiler warning that complained about an "unchecked put." I read somewhere that this can be fixed by specifying the data type of the map at instantiation. So, I tried this:
DBFRecord<String, Object> record = new DBFRecord<String, Object>();
and the compiler, instead of being pleased, slapped me with an error:
"type com.svcon.jdbf.DBFRecord does not take parameters"
So, just to prove the point, I tried:
HashMap<String, Object> record = new HashMap<String, Object>();
and it worked perfectly (though of course it messed up the rest of the program royally.)
My question, then, is this: How does one declare a child class (if that's the right term) such that it takes the same parameters as the parent?