I know how loops work but I wasn't sure how I could check the last index of the string I am iterating over in this case. Here is an example:
String words = "Apple gum fruit red orange triangle";
for(String foo : words.split("\\s+"){
//How would I get the index of foo at any given point in the loop
}