wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Using MAp Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Using MAp Problem" Watch "Using MAp Problem" New topic
Author

Using MAp Problem

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634



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 ?



OCPJP 6.0 93%
OCPJWCD 5.0 98%
Malatesh Karabisti
Ranch Hand

Joined: Jul 28, 2010
Posts: 153

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

Joined: Apr 06, 2010
Posts: 4343
    
    8

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

Joined: May 18, 2010
Posts: 634

i am using jcreator lite

jdk 1.6
Prabhakar Reddy Bokka
Ranch Hand

Joined: Jul 26, 2005
Posts: 189

Mohit,

The code posted by Malatesh works perfectly alright. Did you tried??


SCJP 5, SCWCD 5
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

Which error are you getting?


[uaiHebert.com] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

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


SCJP6.0,My blog Ranchers from Delhi
 
jQuery in Action, 2nd edition
 
subject: Using MAp Problem
 
Similar Threads
HashMap Duplicate Element Problem
Using classes as Keys in Map problem
HashMap and hashCode()
Doubt regarding working of equals() and hashCode() methods
Confusion regarding the default constructor