This creates a variable named myfeelings and stores the text "I love Gorillas" in it. It then checks for the position of the word "I," which it finds, and prints out its position (positions begin with 0). Then it looks for the word "love" and finds it begins at the 2 position (the l that starts the word is the second character in the string). Next it looks for the text "to eat" in the variable, and does not find it. Because it is not in the string, and therefore its position cannot be found, it results in the number -1. Any time info is not found, it will return -1.
Lastly, it searches for the word "Gorillas" (my all time favorite word) and finds it located in position 7. Here are the results of the program:
0 2 -1 7
Note that the IndexOf() method is case-sensitive. If I had told it to find "gorillas" in the string, it would not have worked and returned a -1 for its position.