kindly explain the scanner class
Scanner class unable to understand
why we have used scn and new and then system.in i am unable to understand the 2 lines : scannner scn = new (system.in )
please explain this
@Nitya_Somani okay nitya, so here is my two cents on the explanation.
See scanner is a class in java. So here we are making object of Scanner so that we can call the input methods on it.
So Scanner s = new Scanner(System.in); So here left part is a reference(s) more like a name, and right part is an object.
you can think like that:-
Human raj = new Human(), so here we have made a human object whose name is raj. so raj refers the object.
You will learn more while studying oops.
And System.in is an InputStream which is typically connected to keyboard input of console programs.
So if you have any query feel free to ask else mark the doubt resolve and rate full!