input is
Code
80 90
You then print enteredGrades, which it shows.
You then set firstIndex to 0, spaceIndex to enteredGrades.indexOf(" ") which is 2, and lastIndex as spaceIndex + 1 which is 3
You then print firstIndex, spaceIndex, and lastIndex which it shows
You then set programString to enteredGrades.substring(firstIndex, spaceIndex) which is substring(0,2). Which returns a string starting from firstIndex of length spaceIndex - firstIndex, which is 2. Setting programString to "80". You trim whitespace, which there is none, parse it to an int, and then print it. Which it shows.
You then set examString to be enteredGrades.substring(lastIndex, enteredGrades.length()-1) which is substring(3, 4) since enteredGrades.length() is 5. This returns a substring starting from lastIndex of length enteredGrades.length()-1-lastIndex which is 5-1-3 which is 1. Setting examString to "9". Trim it, parse it. print it. Which it shows