Here "String" is not java.lang.String
, it is a type parameter declared with the definition of the treemap class.
You are working in a generic class, and String
is a type variable of this class.
In other words, this :
class treemap<String, Integer> {
private class node {
String word;
int line;
node left;
node right;
node(String wd, int ln){
word=wd;
line=ln;
}
}
private node root;
public treemap(){
root=null;
}
...Has the same meaning that this :
class treemap<T, U> {
private class node {
T word;
int line;
node left;
node right;
node(T wd, int ln){
word=wd;
line=ln;
}
}
private node root;
public treemap(){
root=null;
}
If you want T to extend String and U to extend Integer, then you should define your class like that :
class treemap<T extends String, U extends Integer> {