+ 1

Please explain me the significance of new keyword in scanner

22nd Dec 2019, 3:41 AM
Nitin pandey
Nitin pandey - avatar
6 Respostas
+ 4
The "new" keyword not only for Scanner class but for any class in Java helps in creating the instance(object) of the class. So "new" keyword is responsible for object creation and the object is created in the heap memory but the reference variable pointing it is stored in the stack.
22nd Dec 2019, 3:59 AM
Avinesh
Avinesh - avatar
+ 1
Nitin pandey You're welcome
22nd Dec 2019, 4:07 AM
Avinesh
Avinesh - avatar
+ 1
New keyword is used to create an object of the class If you have Student class then you create a object of it like this Student obj = new Student (); Scanner is also a class in java it is in built-in class in java when we use this class we create an object of it like the Scanner obj = new Scanner(System.in);
22nd Dec 2019, 11:08 PM
Asad Shar
Asad Shar - avatar
+ 1
23rd Dec 2019, 8:16 AM
Nitin pandey
Nitin pandey - avatar
+ 1
You are welcome
23rd Dec 2019, 8:18 AM
Asad Shar
Asad Shar - avatar
0
Thanks Avinesh ✌️✌️
22nd Dec 2019, 4:04 AM
Nitin pandey
Nitin pandey - avatar