+ 1

How to take input as name of a person and use it in a class?

How can we take name as a input form the user and use it in a class such as NameOfThePerson.Age

12th Jan 2018, 10:06 AM
Bibek Rajbanshi
Bibek Rajbanshi - avatar
1 Answer
0
The class Scanner is the easiest way to take inputs directly from the user and just place the value provided into a variable that you can use as a parameter or however you like, just consider the implementation in your class design, cause "NameOfThePerson" looks like an instantiated reference variable (an Object of a class) calling the method or class variable "Age" instead of a variable capable of receiving a value directly.
12th Jan 2018, 3:50 PM
Roberto Guisarre
Roberto Guisarre - avatar