+ 2
What is the use of - new <class name>() ?
I have seen this while importing scanner class new scanner (System.in) and while creating objects
2 Respuestas
+ 1
scanner is actually a class define in one of the Java library Oracle so kindly wrote for us. Unless an object or its method is static, we need to instantiate an object before we can use any of its member methods.
+ 1
"New class();" calls the constructor of the class and builds an object based on that class' definition.