我通過一個叫做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);
}
}
當我編譯它,它給了我論文的錯誤:
'isInvaildWord' - >應該是'isInvalidWord' –
標記爲由於拼寫錯誤而關閉此問題。 – CubeJockey
@CubeJockey問題不是拼寫錯誤。新手的錯誤並沒有解釋編譯器所說的內容。 –