title: java.lang.ArrayIndexOutOfBoundsException: 4 Error
body: <p>I'm new to coding and I've been writing this code and trying to make it work but every time I run it it crashes. I've looked things up and will writing this code I've followed java's website on how to properly write down code as well as this site.</p>
  
  <p>Anyways, it would be greatly appreciated if someone can explain to me why this is not working because it seems to me like the logic is there but I don't get why it crashes.</p>
  
  <p>My code:</p>
  
  <pre><code>    import java.util.Scanner;
      import java.lang.String;
      import java.util.*;
      public class Question1
      {
        public static void main(String[] args)
            {
               Scanner keyboard= new Scanner(System.in);
               System.out.println("Enter either letters or numbers and I'll magically tell you if they are consecutive :D");
               String inputedString= keyboard.nextLine();
               boolean consecutiveOrNot=isConsecutive(inputedString);
               System.out.println("Drum rolls...... Is it consecutive: "+ consecutiveOrNot);  //Problem with this line?
            }
  
  
        public static boolean isConsecutive(String inputedString)
            {
              //Storing string's units into an array and converting to UpperCase if necessary
              //and storing string's numerical value into the variable 'arrayCharToInt'
                char[] charIntoArray= new char[inputedString.length()];
                int[] arrayCharToInt= new int[inputedString.length()];
                for (int i=0;i&lt;inputedString.length();i++ )
                  {
                     charIntoArray[i]=inputedString.charAt(i);
                      if (Character.isLetter(charIntoArray[i]) &amp;&amp; Character.isLowerCase(charIntoArray[i]))
                       {
                          charIntoArray[i]= Character.toUpperCase(charIntoArray[i]);
                        }
                      arrayCharToInt[i]=(int) charIntoArray[i];
                  }
  
  
  
  
             // The next if statements and the methods that they call are used to verify 
             //that the content of the initial string is either letters or numbers, but not both together
                boolean[] continuous= new boolean[arrayCharToInt.length];
                boolean[] testContNumbersDecreasing= new boolean[arrayCharToInt.length];
                boolean[] testContNumbersIncreasing= new boolean[arrayCharToInt.length];
                boolean[] testContLettersDecreasing= new boolean[arrayCharToInt.length];
                boolean[] testContLettersIncreasing= new boolean[arrayCharToInt.length];
                Arrays.fill(continuous, true);
                 if (lowestValue(arrayCharToInt)&gt;=65 &amp;&amp; highestValue(arrayCharToInt)&lt;= 90)
                  {
                      for (int x=0;x&lt;arrayCharToInt.length ;x++ ) 
                      {
                         testContLettersIncreasing[x]=((arrayCharToInt[x+1]-arrayCharToInt[x]== 1) || (arrayCharToInt[x+1]-arrayCharToInt[x]== -25));
                         testContLettersDecreasing[x]=((arrayCharToInt[x]-arrayCharToInt[x+1]== 1) || (arrayCharToInt[x]-arrayCharToInt[x+1]== -25));
                      }
                      return (Arrays.equals(continuous,testContLettersIncreasing) || Arrays.equals(continuous,testContLettersDecreasing));
                  }
  
                 else if ((lowestValue(arrayCharToInt) &gt;= 48) &amp;&amp; (highestValue(arrayCharToInt)&lt;= 57))
                  {
                      for (int x=0;x&lt;arrayCharToInt.length ;x++ ) 
                      {
                         testContNumbersIncreasing[x]=((arrayCharToInt[x+1]-arrayCharToInt[x]== 1) || (arrayCharToInt[x+1]-arrayCharToInt[x]== -9));
                         testContNumbersDecreasing[x]=((arrayCharToInt[x]-arrayCharToInt[x+1]== 1) || (arrayCharToInt[x]-arrayCharToInt[x+1]== -9));
                      }
                      return (Arrays.equals(continuous,testContNumbersIncreasing) || Arrays.equals(continuous,testContNumbersDecreasing));
  
                  }
                else
                  {
                      return false;
                  }
  
            }
  
  
  
        public static int lowestValue(int[] array)
            {
                  int lowest=array[0];
                    for (int counter=0; counter&lt; array.length; counter++)
                      {
                        if( lowest&gt;array[counter])
                              lowest= array[counter];
                      }
                      return lowest;
            }
  
        public static int highestValue(int[] array)
            {
                 int highest=array[0];
                  for (int counter=0; counter&lt; array.length; counter++)
                      {
                        if( highest&lt;array[counter])
                          highest= array[counter];
                      }
                  return highest;
            }
  
      }
  </code></pre>
  
  <p>The main method seems to be fine because it put everything in the isConsecutive method as a comment except for 'return true;' and indeed the program ran and printed true. So I know the problem lies somewhere in the second method.</p>
  
  <p>If there's anything that I did not do right please tell me and that would be greatly appreciated. After all I'm still learning.</p>
  
  <p>Thanks</p>