[英]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
这意味着您应该键入class
或interface
(在您的情况下,应为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");
}
}
class
。 Document
从哪里来?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.