Java can't find method main

后端 未结 7 2134
孤街浪徒
孤街浪徒 2021-01-20 10:45

Im having trouble with a simple hello world program lol! Im hoping someone can shed some light on this.

So the error im receiving is the following:

$         


        
7条回答
  •  耶瑟儿~
    2021-01-20 11:29

    Problem is that your method does not take String array as a argument. Use following signature instead:

    public static void main(String[] argv)
    

    or

    public static void main(String argv[])
    

    Other valid option is:

    public static void main(String ... argv)
    

    In Java Language Specification this is told as follows:

    The method main must be declared public, static, and void. It must specify a formal parameter (§8.4.1) whose declared type is array of String.

提交回复
热议问题