2016-07-06 49 views
-5

我通過一個叫做Treehouse的網站來學習java,我遵循了老師所說的一切,但是我的代碼不工作。(錯誤在Java代碼中)'錯誤:無法找到符號'和'錯誤非法啓動類型'

這是代碼我寫:

import java.io.Console; 

public class TreeStory { 

    public static void main(String[] args) { 
     Console console = System.console(); 
     /* Some terms: 
      noun - Person, place or thing 
      verb - An action 
      adjective - A description used to modify or describe a noun 
      Enter your amazing code here! 
     */ 
     String ageAsString = console.readLine("How old are you?: "); 
     int age = Integer.parseInt(ageAsString); 
     if (age < 13) { 
      //Insert exit code 
      console.printf("Sorry, you must be atleast 13 to use this program.\n"); 
      System.exit(0); 
     } 
     String name = console.readLine("Enter a name: "); 
     String adjective = console.readLine("Enter an adjective: "); 
     String noun; 
     boolean isInvalidWord; 
     do { 
      noun = console.readLine("Enter a noun: "); 
      isInvalidWord =(noun.equalsIgnoreCase("dork") || 
            noun.equalsIgnoreCase("jerk")); 
      if (isInvaildWord) { 
      console.printf("That language is not allowed. Try again. \n\n"); 
      } 
     } while(isInvaildWord); 
     String adverb = console.readLine("Enter an adverb: "); 
     String verb = console.readLine("Enter a verb ending with -ing: "); 

     console.printf("Your TreeStory:\n---------------------\n"); 
     console.printf("%s is a %s %s. ", name, adjective, noun); 
     console.printf("They are always %s %s. \n", adverb, verb); 
    } 

} 

當我編譯它,它給了我論文的錯誤: picture if console

+5

'isInvaildWord' - >應該是'isInvalidWord' –

+1

標記爲由於拼寫錯誤而關閉此問題。 – CubeJockey

+0

@CubeJockey問題不是拼寫錯誤。新手的錯誤並沒有解釋編譯器所說的內容。 –

回答

-1

你只有一個錯字:

命名爲isInvalidWord的變量和用作isInvaildWord(反轉的i和d)

+0

謝謝,我怎麼會這麼盲目。 – Tfahami

+0

總是有趣的看到downvote正確的答案。我認爲這總是一個糟糕的問題。 –

相關問題