aspose file tools
The moose likes Java in General and the fly likes TreeMap: why aren't these code working? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "TreeMap: why aren Watch "TreeMap: why aren New topic
Author

TreeMap: why aren't these code working?

kei hosima
Greenhorn

Joined: Feb 23, 2003
Posts: 13
Hello.
I can't figure out why the following code is not working. Hope someone could help me.
First one is 'remove( )'
I want to check if the nameField is in the collection or not.
If it is in the collection, I want to remove it from the collection.
I'm using SortedMap m = new TreeMap();

I have the following error message
"method remove(java.lang.String, project06.App.Employee) not found in interface java.util.SortedMap"
the second is "firstKey"
I want to make sure if the collection is empty or not. If it's empty, show an error message. if it's not empty, show the first record in the collection.

The following is the error message I'm getting:
"method firstKey(java.lang.String, <any> not found in class project06.App"
Finally, get( ).
I want to find a specific record from the collection.
The following is my code.

The following is the error message
"method get(java.lang.String, double) not found in interface java.util.SortedMap"
I would appreciate any suggestion/help/advice.
Thanks in advance.
[ March 31, 2003: Message edited by: Cindy Glass ]
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
msg.setText (m.get(nameField.getText(), Double.parseDouble(payRateField.getText())));
Map.get takes one argument, an Object.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
kei hosima
Greenhorn

Joined: Feb 23, 2003
Posts: 13
thank you very much for your reply.
I changed to
msg.setText("We found " + m.get(nameField.getName()));
I'll try to see if it would work or not.
 
 
subject: TreeMap: why aren't these code working?
 
Threads others viewed
Using a class method of an object stored in a TreeMap
Help!! Runnable Interface Problem!!!
Input in Java
How do I triggers object and add them to the collection?
TreeMap Strange
developer file tools