Java - Cannot find symbol constructor

前端 未结 5 516
我在风中等你
我在风中等你 2021-01-15 03:23

I\'m completely new to Java, so I\'m sorry if my question is dumb. Im working on this assignment, and I\'ve been reading about main methods for hours now, but I just cant fi

5条回答
  •  佛祖请我去吃肉
    2021-01-15 04:17

    When your class explicitly defines constructor, implicit no-arg constructor won't be created.

    You have explicit constructor in your class

    public Player(String nickName, String playerType) 
    {
    
        nick = nickName;
        type = playerType;
        health = 100;
        System.out.println("Welcome " + nick +" the " + type + ". I hope you are ready for an adventure!");
    }
    

    And trying to invoke no-arg constructor

     Player player = new Player();
    

    Either you need to pass parameters in above code (or) create no-arg constructor.

提交回复
热议问题