[英]java Hello World Error: Main method not found in classname, please define the main method as: public static void main(String[] args)
I don't understand why I'm getting an error here code below:我不明白为什么我在下面的代码中收到错误:
public class Lab1HW { public static void main(String[] args) {公共 class Lab1HW { 公共 static 无效主(字符串 [] 参数) {
System.out.println("Computer Science, Yes!!!!");
}
} }
do following steps: write code as:执行以下步骤:将代码编写为:
public class Lab1HW{
public static void main(String[] args){
System.out.println("Computer Science, Yes!!!!");
}
}
then save file using same name as class name.然后使用与 class 名称相同的名称保存文件。 in you case Lab1HW.java then you have to compile and run.. output will be
在你的情况下 Lab1HW.java 那么你必须编译并运行.. output 将是
Computer Science, Yes!!!!
your code seems fine, just try writing it this way or first try running it on an online compiler.
您的代码看起来不错,只需尝试以这种方式编写它或首先尝试在在线编译器上运行它。
public class Lab1HW{
public static void main(String[] args){
System.out.println("Computer Science, Yes!!!!");
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.