+ 1
Please explain me the significance of new keyword in scanner
6 Respuestas
+ 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.
+ 1
Nitin pandey You're welcome
+ 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);
+ 1
Tysm Asad Shar
+ 1
You are welcome
0
Thanks Avinesh ✌️✌️