0
In order to use the "class" from the java.util package. is it necessary to create object?
If yes means then why we shouldn't create "object" in simple Java program at all time. https://code.sololearn.com/cZu88U0tilXE/?ref=app
6 Respuestas
0
System is a class and 'in' is a reference variable of type InputStream. You can get more details here.
https://docs.oracle.com/javase/7/docs/api/java/lang/System.html
System.in is passed to scanner class object to specify that it should except input from any input stream, could be a keyboard stroke or a file etc.
0
No
0
You need not create objects of classes at all times because they are either created for you and are assigned the static and final keyword so that you can call the methods on them directly.
For eg- out is an object from PrintStream class and you directly call the print method on it. But this is from java.lang package.
But to use scanner object from the java.util package, generally we say-
new Scanner(System.in)
You need not use the new keyword everytime. You can understand it better from the respective class definitions.
0
Abhay then why we create a object while we using a scanner class to get a user's input.
If we able to do it without creating object to get user's input then explain it with codebits
https://code.sololearn.com/cq032kxCt7iw/?ref=app
0
Avinesh bro thanks but I don't know what is the "system.in" in
new Scanner (System.in)?
0
Avinesh bro thanks....