Java - Cannot find symbol constructor

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

    Player has no no-arg constructor, you could use:

    Player player = new Player("My Nickname", "Player Type");
    

    If you wish to prompt the user for the Player arguments, you can read like so:

    Scanner scanner = new Scanner(System.in);
    System.out.print("Enter Player Name:");
    String nickName = scanner.nextLine();
    System.out.print("Enter Player Type:");
    String playerType = scanner.nextLine();
    Player player = new Player(nickName, playerType);
    

提交回复
热议问题