I have the following code to split a String of a list of words separated by spaces. The string is split and used to populate the array. If I use the .length method, will it return the amount of split strings? As in, would it be similar to the String.length method that counts the amount of characters and returns that value?
I want to have the program increment the array position by one each time it's run, but I want it to reset to 0 if it already used the last word, so it circles back and starts with the first word again.
Would this bit of code reset the word position to 0 when it has already used the last word in the array?
String wordsList[] = words.split(" ");
this.currentWord = wordsList[wordPos];
if(wordPos < wordsList.length)
wordPos++;
else
wordPos = 0;