Answer the question
In order to leave comments, you need to log in
How to pass console input to a constructor parameter in Java using Scanner?
There is a class Gamer.java and a String variable private String name.
How can I pass it to the constructor parameter so that when a new object of the Gamer class is created IN ANOTHER class, the name is entered from the console using Scanner?
Answer the question
In order to leave comments, you need to log in
In ANOTHER class, enter the name from the console using Scanner and pass it to the constructor of the Gamer class when creating its new object instance.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question