Sponsored Link •
|
Advertisement
|
Advertisement
|
This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.
Message:
Don't be so hard on Chin, he is really just trying to help you by geting you to help yourself. It's "tough love." Below is what I meant by filling out an array of ints. Using the map would be easy, too and you should give that a try for your own edification. It is exactly the same concept as I've done with the array, except the map keys could actually be the letters themselves (rather than an index) and the other item could be the string "other" or whatever you like. Also, on your point of getting confused and forgetting what you know by looking at the book, I couldn't agree less! The mind is not limited to a fixed amount of knowledge, it expands as you learn. The more you know, the more you want to know and the more you realize how little you know. (That explains why teenagers often believe they are smarter and more knowledgible than their elders!) - mfg
> I'll try to contemplate more and perhaps figure out the answer myself. > > > charAt() - to get the specific character from the string, and possibly the array, and compare both to see whether it's equal or not. > > what i mean in "array" here is the "array" of your character list in the form of String. i.e. String charlist="abcde...". sorry to use the word "array" there. it doesn't literally mean the word array as in charlist[]. > > > indexOf() - well this is just to save you from looking at redundant characters, rather than checking every characters from the *beginning* of the array of either your string or character list (you can store your character list as a string, or well, an array), you just use indexOf() to get the first occurence of the character. > > again, what i mean here is that, if you store your character list in the form of array (charlist[]) you would have to fetch every single character from the beginning itself to find out which letter was it. so, rather than all that hassle, an easier way is to store the character list as a String and retrieve the first occurence of the specific character (to know which character it is). > > // after u get the loc (which is of value zero, 0,
Replies:
|
Sponsored Links
|