Errors that don't exist

Umm. This is awkward but I'm getting some errors that say stuff that is totally untrue.

Could someone give me a suggestion on how to fix it. I'm new to java so simple answers would be the best.

Thanks.

 public class Project1
    {
    public static void main( String [] args )
    {
        System.out.println();
        String output = new String();
        String inital = new String();
        inital = english_to_morse();

        for( int k = 0; k < inital.length(); k++)
        {
            output += morse(inital.charAt( k ));
        }

            System.out.print(output);
            System.out.println();
    }
        public static void choice()
    {
        int user_choice = 0; ///This is the method giving me grief!!!!!!
        user_choice = Input.getInt("Enter 1 if you want to change English to Morse code, and enter 2 to change Morse code to English");
        if(user_choice == 1)
        {
            english_to_morse();

        }
        if(user_choice == 2)
        {
            morse_to_english();
        }

    public static String english_to_morse() 
    {
      String user_input = new String();

      user_input = Input.getString("Enter a phrase and I'll convert it to Morse Code");

      return user_input.toLowerCase();
    }

    public static String morse_to_english() 
    {
      String user_input = new String();

      user_input = Input.getString("Enter a phrase in Morse Code and I'll convert it to English");

      return user_input.toLowerCase();
    }

    public static String morse(char letter)
    {
        String output = new String();
        char[] alphabet_numbers = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ' ' };
        String morse_code[] = { ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", "-----", ".----", "..---", "...--", "....-", ".....", "-....", "--...", "---..", "----.", "|" };

        for( int j = 0; j < alphabet_numbers.length; j++ )
        {
            if (alphabet_numbers[j]==letter)
            {
                output = morse_code[j];
            }
        }
        return output + " ";
    }   
}
Jon Skeet
people
quotationmark

This is the problem:

public static void choice()
{
    int user_choice = 0; ///This is the method giving me grief!!!!!!
    user_choice = Input.getInt("Enter 1 if you want to change English to Morse code, and enter 2 to change Morse code to English");
    if(user_choice == 1)
    {
        english_to_morse();

    }
    if(user_choice == 2)
    {
        morse_to_english();
    }

public static String english_to_morse() 

You never finish the choice() method - so you can't start the english_to_morse method.

I strongly suspect that the first error message from the compiler was at the start of the english_to_morse method. Once you're source is that broken (trying to declare one method inside another) it shouldn't be a surprise that other error messages may seem strange.

It's a good idea to:

  • Compile often, and fix problems as soon as they occur. Then if you suddenly get a slew of errors, you know that it can only be due to what you've done very recently.
  • A huge number of errors is usually due to something like this - look at the first error message, or at least where you start getting a lot of errors, and that can often find the problem.
  • Getting the IDE to format your code can help you find missing braces too.

people

See more on this question at Stackoverflow