title: Java: Cannot make static reference to non static method
body: <p>I have this class that I'm trying to use to find the number of vowels and number of consonants in a string.</p>
  
  <pre><code>import java.lang.String;
      public class vowelsAndConsonantsClass
      {
        private int vowels;
        private int consonants;
        public vowelsAndConsonantsClass(int vwls, int cons)
        {
          vowels = vwls;
          consonants = cons;
        }
          public void numberOfVowels(String str)
          {
            int vwls = 0;
            for(int i=0; i&gt;str.length(); i++)
            {
              if(str.charAt(i) == 'a' || str.charAt(i) == 'e' || str.charAt(i) == 'i' || str.charAt(i) == 'o' || str.charAt(i) == 'u' || str.charAt(i) == 'y');
              vwls++;
            }
          }//end numberOfVowels 
          public void numberOfConsonants(String str)
          {
            int cons = 0;
            for(int i=0; i&gt;=str.length(); i++)
            {
              if(str.charAt(i) != 'a' || str.charAt(i) != 'e' || str.charAt(i) != 'i' || str.charAt(i) != 'o' || str.charAt(i) != 'u' || str.charAt(i) != 'y');
              cons++;
            }
          }//end numberOfConsonants
          public int getNumberOfVowels()
          {
            return vowels;
          }
          public int getNumberOfConsonants()
          {
            return consonants;
          }
      }//end class
  </code></pre>
  
  <p>I'm trying to use this test input when I get the error. I will comment the line it is on.</p>
  
  <pre><code>import java.util.Scanner;
  import java.lang.String;
  public class testVowelsAndConsonants
  {
    public static void main(String[] args)
    {
      Scanner keyboard = new Scanner(System.in);
      int choice;
      System.out.println("Please enter a string.");
      String str = keyboard.nextLine();
      choice = menu(keyboard);
      Character.toLowerCase(choice);
      switch(choice)
      {
        case 'a':
          System.out.println(vowelsAndConsonantsClass.getNumberOfVowels());//ERROR ON THIS LINE
          break;
        case 'b':
          break;
        case 'c':
          break;
        case 'd':
          break;
        case 'e':System.exit(0);
      }
    }
    public static int menu(Scanner keyboard)
      {
      int choice;
      System.out.println("Enter a to count the number of vowels in the string.\n"+
                         "Enter b to count the number of consonants in the string.\n"+
                         "Enter c to count both the vowels and consonants in the string.\n"+
                         "Enter d to enter another string.\n"+
                         "Enter e to Exit.\n");
      do
      {
        choice = keyboard.nextInt();
      }
      while(choice&lt;1||choice&gt;6);
      return choice;
    }//End menu
  }
  </code></pre>
  
  <p>Please note that I'm not 100% done with the test data. I'll finish it once I understand the error. Thanks in advance.</p>