+ 1

"scanner myvar = new" is new a value here? Like saying this is empty for now?

30th Aug 2017, 6:30 PM
Yuko
Yuko - avatar
3 Respostas
+ 6
new is a keyword, not a value. new is used to create an instance of a class (object).
30th Aug 2017, 6:35 PM
Tashi N
Tashi N - avatar
+ 6
Scanner scnr = new Scanner(); From what I can tell, your declaration is simply incomplete. The statement I posted above is how you would go about declaring a scanner object. The "new Scanner()" part of it lets it know to instantiate a new object from the scanner class. In my example, we're storing a reference to that new object in the "scnr" variable so we can use it.
30th Aug 2017, 6:37 PM
AgentSmith
0
Scanner obj=new Scanner(System.in); Scanner is the class whose object is to be created, 'new' is the keyword which creates the object named 'obj'
4th Dec 2017, 5:08 PM
friendly_nadim
friendly_nadim - avatar