Final answer:
The output onto the console will be: -1, 3, 3.
Step-by-step explanation:
The output onto the console will be:
Step-by-step explanation:
- In the first System.out.println statement name.indexOf(letter), the variable letter is assigned the value 'D'. However, there is no 'D' in the string name, so the output will be -1.
- In the second System.out.println statement letters.indexOf(name.substring(3,4)), the substring name.substring(3,4) is 'e'. The string letters has 'e' at index 3, so the output will be 3.
- In the third System.out.println statement letters.indexOf(letter), the variable letter is 'D'. The string letters has 'D' at index 3, so the output will be 3.