Hi there, I'm having issues with my program. Only one part of the driver program is having issues. For that reason, I've only attached a small section of the code. I was wonder if anyone would be kind enough to explain why I keep having the errors:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range
here is the code:
import java.util.Scanner; public class characterTest { public static void main(String [] args) { Scanner input = new Scanner(System.in); String str; System.out.println("Enter string"); str = input.next(); int i, count3 = 0; for (i = 1; i <= str.length(); i++) { if (Character.isUpperCase(str.charAt(i))) count3++; } System.out.println("your upper char: " +count3); } }
Thank you for any advice!