• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using MAp Problem

 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


ToDos CLass is defined and it extends Comparator
The above gives the following error:


type Map does not take parameters
{ Map<ToDos,String> m=new TreeMap<ToDos,String>()


can anyone tell why ?


 
Malatesh Karabisti
Ranch Hand
Posts: 153
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you are using IDE. try compiling using command and post the exact error message.I didn't get any error for following code. by the way what is the version of your JDK ?

 
Matthew Brown
Bartender
Posts: 4566
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Java version is the first thing I'd check. If it's 1.4 or earlier then it won't understand generics.
 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using jcreator lite

jdk 1.6
 
Prabhakar Reddy Bokka
Ranch Hand
Posts: 197
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohit,

The code posted by Malatesh works perfectly alright. Did you tried??
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it may be possible that you will be having a same class in the same package with the same name.i.e ToDOs.

So compiler is taking that class intead of the one which is implementing the comparator.
Have a check..Otherwise code should work fine
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic