title: Java Error - array required, but java.lang.String found
body: <p>I've been working on this problem for a while and managed to get rid of almost all the errors on this program. Every time I compile I seem to get this error saying "array required, but java.lang.String found." I'm really confused on what this means. Can someone help me please? I've been struggling a lot. </p>
  
  <pre><code>import java.util.Scanner;
  public class Period
  {
    private static String phrase;
    private static String alphabet;
    public static void main(String [] args)
    {
      Scanner keyboard = new Scanner(System.in);
      String userInput;
      int[] letter = new int [27];
      int number = keyboard.nextInt();
      System.out.println("Enter a sentence with a period at the end.");
      userInput = keyboard.nextLine();
      userInput.toLowerCase();
    }
  
    public void Sorter(String newPhrase)
    {
      phrase=newPhrase.substring(0,newPhrase.indexOf("."));
    }
  
    private int charToInt(char currentLetter)
    {
      int converted=(int)currentLetter-(int)'a';
      return converted;
    }
  
    private void writeToArray()
    {
      char next;
      for (int i=0;i&lt;phrase.length();i++)
      {
        next=(char)phrase.charAt(i);
        sort(next);
      }
    }
  
    private String cutPhrase()
    {
      phrase=phrase.substring(0,phrase.indexOf("."));
      return phrase;
    }
  
    private void sort(char toArray)
    {
      int placement=charToInt(toArray);
      if (placement&lt;0)
      {
        alphabet[26]=1; // This is here the error occurs.
      }
      else
      {
        alphabet[placement] = alphabet[placement] + 1; // This is where the error occurs.
      }
    }
  
    public void entryPoint()
    {
      writeToArray();
      displaySorted();
    }
  
    private void displaySorted()
    {
      for (int q=0; q&lt;26;q++)
      {
        System.out.println("Number of " + (char)('a'+q) +"'s: "+alphabet[q]); //this is where the error occurs.
      }
    }
  }
  </code></pre>