+ 3

Scanner why system.in is used

import java.util.Scanner; class MyClass { public static void main(String[ ] args) { Scanner myVar = new Scanner(System.in); System.out.println(myVar.nextLine()); } }

26th May 2018, 11:41 AM
Samarth Madan
Samarth Madan - avatar
5 Respuestas
+ 7
You can simply understand by this that, 'System.out' (System.out.print) is used to print (to give) Conversely, 'System.in' is used to accept (to take) values.
26th May 2018, 12:46 PM
Mayank Rampuriya
Mayank Rampuriya - avatar
+ 3
System is a class in the java.lang package. System.in is an InputStream which is typically connected to keyboard input of console programs. System.in is notused as often since data is commonly passed to a command line Javaapplication via command line arguments https://docs.oracle.com/javase/7/docs/api/java/lang/System.html
26th May 2018, 11:45 AM
MsJ
MsJ - avatar
+ 3
I'm also new to java, so don't mind me if I made some mistakes.
26th May 2018, 11:48 AM
Amar
Amar - avatar
+ 1
https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html Scanner is class that enables you to take user input. As you can see in this page, it can be file, user input from keyboard etc. System.in is parameter for Scanner constructor that indicates keyboard input.
26th May 2018, 11:48 AM
Amar
Amar - avatar
+ 1
Its accessing the System class, the out method (default keyboard input) and the println method.
27th May 2018, 9:28 AM
Apple Blossom
Apple Blossom - avatar