This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
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


Win a copy of Head First Android this week in the Android forum!
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: 4537
    
    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: 193

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, 3rd edition
 
subject: Using MAp Problem
 
jQuery in Action, 3rd edition