Java - Cannot find symbol constructor

前端 未结 5 473
我在风中等你
我在风中等你 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:01

    A default constructor is created by java when a construtor is missing, this construtor simply calls the super class. When you defined an explicit constructor java wont create one. So you can either define one default constructor in your class e.g.

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

    or modify the code to call the constructor u defined.

     Player player = new Player("nick","type");
    

提交回复
热议问题