File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Using MAp Problem" Watch "Using MAp Problem" New topic

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

Joined: Apr 06, 2010
Posts: 4544

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: 195


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

Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

Which error are you getting?

[] [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
I agree. Here's the link:
subject: Using MAp Problem
jQuery in Action, 3rd edition