Originally posted by lynn fann: can have example? i have never try linkhashset before thanks.
Lynn,
If this is a homework question, I highly doubt your instructor would allow the use of regular expressions, the linkedhashset, or anything else that you have not learned yet.
So... what have you learned? I am assuming that you just learned about loops? Or have you learned about collections yet (which will allow the set)?
In any case, I would recommend that you start with what you know, and start to build the example yourself. You will get more responses, if you ask a question about an issue, once you tried it first.
Originally posted by lynn fann: IF YOU ARE NOT GOING TO HELP, THEN DONT TALK SO MUCH. IS A COMPANY PROJECT ALREADY. IM NEW TO JAVA.
Lynn,
JavaRanch is a site devoted to Learning Java. It is also a moderated site. As such, you are requested in following certain rules -- including this, this, and this. Now, as for this last one, this may not be homework, but it is a common question that is used for learning java.
Now you are getting close to violating the Ranch's "Be Nice" rule, which is not tolerated here.
Henry
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted
0
(I can't see it as being anything but homework)
Anyway, you would do it exactly the same way as if you were doing it on paper: look at the letter, then look at the other letters and remove matches.
the String methods you are likely to use are charAt() indexOf() lastIndexOf()
and, if you end up doing this in a loop, it might be better for you to work backwards
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
posted
0
I actually kind of liked the Set approach. Look at the doc - What does it do if you try to put in two objects that are equals()? You could put every letter in the string and the Set would contain exactly what you're after. It's likely less efficient - have to convert chars into objects of some kind - but pretty well self-documenting.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi