public void main(String[] args) {
System.out.println("Hello World!");
}
This compiles in my environment, but nothing happens at run time.
If should be a static method, otherwise it can't serve as the entry point of a Java application.
public static void main(String[] args)
------
{
System.out.println("Hello World!");
}
主要方法应为: public static void main(String[] args)
public void main(String[] args)
更改为
public static void main(String[] args)
main()
method syntax is,
public static void main(String[] args)
you are missing static
, so JVM
not able to find your main()
method ie entry point so there is noting happened.
Check your console It should display error message as
java.lang.NoSuchMethodError: main
Exception in thread "main"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.