• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

TreeMap: why aren't these code working?

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
msg.setText (m.get(nameField.getText(), Double.parseDouble(payRateField.getText())));
Map.get takes one argument, an Object.
 
kei hosima
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic