簡體   English   中英

這種方法有什么問題?

[英]What's wrong with this method?

我是Java的新手,有人可以向我解釋這種方法有什么問題:

clas Hello {
public static void main (String[]arg) {
Document.write ("hello world") ; 
}}

這是編譯器的輸出:

Hello.java:1: 'class' or 'interface' expected
clas Hello {
^
1 error

這意味着您應該鍵入classinterface (在您的情況下,應為class

假設您在此處復制/粘貼時遇到錯誤,編譯器報告的問題是:

Hello.java:3: cannot find symbol
symbol  : variable Document
location: class Hello
        Document.write ("hello world") ; 
        ^
1 error

這意味着,編譯器對名為以下類的類一無所知:在這種情況下, 找不到符號意味着什么的Document

也許你想寫:

 System.out.println("Hello world");

完整的運行程序:

public class Hello {
    public static void main(String[] args) {
        System.out.println("Hello world");
    }
}

您可能是這個意思:

public class Hello {
    public static void main(String[] args) {
        System.out.println("hello world");
    }
}
  1. 你拼錯了class
  2. Document從哪里來?
  3. 格式很糟糕。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM