Me and generics have yet to make peace. For something that *seems* so simple, it has been battle after battle.
I'm trying to make a Comparator to help with a sorting task. Below is a hacked down version of the class which still gives the error.
I'm not understanding why it won't compile. The error message doesn't help, because to me it says "Error ...apple does not equal apple!"
I gave it <T extends
String> after having problems with a simple <T>. I figured that it didn't have enough information so I added the constraint. ("extends String" means String or lower in inheritance right?) But still it will not compile if I try to use any String methods on what I believe to be a String. Other attempts just yielded "cannot find symbol" errors. String is in java.lang, so it must be able to find it right? Anyway, any help on this would be great.
Thanks,
Paul
TestComparator.java:7: error: incompatible types
T myVariable = o1.toString();
^
required: T
found: String
where T is a type-variable:
T extends String declared in class TestComparator
1 error