(JAVA) I need to validate that an index is valid of a user entered string : When a user enters a word they then are prompt to enter the first and second index of a substring. I have that much sorted but when I try to validate that the index entered with my if statements below I am getting errors regarding those if statements , any help is greatly appreciated







Here is my code...



import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        
        Scanner scanner = new Scanner(System.in);
        String inputString;

        
        int startIndex;
        int endIndex;
        
        
        System.out.println("Enter a string : ");
        inputString = scanner.nextLine();
        
        
       
        
        System.out.println("Enter the first index of the substring : ");
        startIndex = scanner.nextInt();
        
          if (int startIndex > inputSting.length) {
         System.out.println("Index is not in string length, try again.");
        }
        
        
        System.out.println("Enter the second index of the substring : ");
        endIndex = scanner.nextInt();
        
          if (int endIndex > inputSting.length) {
         System.out.println("Index is not in string length, try again.");
        } 
        
        
        char[] ch = new char[endIndex - startIndex + 1];
        inputString.getChars(startIndex, endIndex + 1, ch, 0);

        
        System.out.println("Output : " + String.valueOf(ch));

    }

}