aspose file tools*
The moose likes Java in General and the fly likes question about treemaps Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "question about treemaps" Watch "question about treemaps" New topic
Author

question about treemaps

Lynn Finley
Greenhorn

Joined: Sep 29, 2002
Posts: 13
I created an array of objects and placed them in a treemap. from the treemap, i have to print the items in the collection from a method and without a method.
I have to get user input to get and remove an employee from collection. (I have to use id as key) But this code is not working, if someone can look at it and point me in the right direction, i would appreciate it.

If anyone can please.....look at this and help i will be forever grateful..
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi,

for(int i=0; i<accts.length; i++)//add objects to treemapaccount.put("ID",accts);

in this statement you put "ID",accts. its not valid. you should use,
treemapaccount.put(((Employee)accts[i]).getID(),accts[i])
try it and let me know if it works..
regards
maulin.
Lynn Finley
Greenhorn

Joined: Sep 29, 2002
Posts: 13
Hey Maulin,
Thank you
When I put that in it allowed me to print my array, however it's printing them twice.
I tried commeting out each of my methods to see if I could get any of them to work it said "Statement Expected"...do you know what this message means??
EmployeeMap.java :55: Statement expected.
public void getName(map m)
^
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
If the compiler is telling you that it expected a statement, then it expected a statement where it found something else. Perhaps you've a problem with brackets. According to Roedy Green's List of Java Error Messages, you may be missing missing a } in a method.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Lynn Finley
Greenhorn

Joined: Sep 29, 2002
Posts: 13
I have checked and double checked all of my brackets. Am i passing the right paramater to my methods? I think I should pass my collection, in order to iterate over to get the user input? Am I anywhere on the right track.
Lynn Finley
Greenhorn

Joined: Sep 29, 2002
Posts: 13
Following is my updated code.
It seems as usual once something is fixed you get 10 more errors. I don't think I understand implementing treemaps much.
I'm getting error messages like
When I try to pass my map collection to the method it tells me incorrect type-- When I try to cast it as an Object it tell's me explicit cast needed to convert?
Also things like getValue() not a method of class java.lang.Object--I thought I was passing the treemap?
can anyone please give me some input.
Lynn Finley
Greenhorn

Joined: Sep 29, 2002
Posts: 13
Its me again.
I finally got the code to work, but because it is so long I was wandering if their was a way that i could pause my out put in between method calls.
Thanks in advance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: question about treemaps