My nitpicker suggested that ......The split() method contains an indexof search. I see the split method in the string class but I can't find a split() class in the JDE and dont understand this suggestion. Any ideas welcome. Thank you.
The Java API shows two variations of the split() method. Neither one uses the term "indexof search". However, the split method returns an array, the elements of which are indexed. Could that be the index you are searching for?
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
I have used the string.split to load an array without any problem. I understand the two variations of the command, the second variation limits the number of times the regular expression will be looked for. I don't understand what was meant either and when I asked Paul he said to post the question about indexof in the Cattle Drive forum.
Here is the whole conversation...
Ask on the cattle drive forum
>On Wed, Oct 21, 2009 at 8:27 PM, MM Gillon wrote:
> I am really confused about this comment.
>> The split() method contains an indexof search. Any
>> chance that you
>> can rewrite this toInt() so that it does this just once?
> The split() is a method in string class and string has the indexOf() but I can't find a split class in the Sun JDE and I only see two versions of the split method in the string reference.
> http://java.sun.com/j2se/1.4.2/docs/api/ >
There is no "split" class. It is a method in the String class.
Consider the indexOf() method. I want you to suppose for a moment that you write the indexOf() method. How would you go about it? Maybe it might even be a good idea to write a bit of code just to help you think through how it works.
Next, consider the split() method. I want you to do the exact same thing.
A solution you sent me used both methods.
I would like to suggest that each of these methods are rather time consuming - not particularly efficient. They are well written and all, but to do what they do just takes a bit of time.
I would even go so far as to speculate that one could create a method much like split() that uses indexOf(). In other words, the functionality of split() is sort of a big brother to indexOf().
So, in your solution, you used indexOf() and you then threw that information away and called split(). I was attempting to suggest that you instead use just one or the other, but not both. And just once. After all, a call to either is a wee bit expensive.
I remember doing development before java and having something called a "function". In java, there is something similar called a "method".
Yes, string class, split method, understood.
I made the change. You need to make the change too.
I am.... but In the languages I work in both still exist. They are interchangable in some revisions of the language and strictly defined in others... I support both and have to use both words with other developers. I am working to correct my usage in the Java forums.
There is, literally, a method called split().
Yes, got it.... my issue was that the way I originally read your comment I was looking for string.split.indexOf() or split.indexOf()