String index out of bounds? (Java, substring loop)
问题 This program I'm making for a COSC course isn't compiling right, I keep getting the error: Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 2 at java.lang.String.substring(String.java:1765) at VowelCount.main(VowelCount.java:13) Here's my code: import java.util.Scanner; public class VowelCount { public static void main(String[] args) { int a = 0, e = 0, i = 0, o = 0, u = 0, count = 0; String input, letter; Scanner scan = new Scanner (System.in);