What is system.in.read() here, where can i find every detail and use of it and where it is in documentation? in classes or whaterver ?
char ch;
ch=(char)System.in.read();
System.out.println("you typed"+ch);
What is system.in.read() here, where can i find every detail and use of it and where it is in documentation? in classes or whaterver ?
char ch;
ch=(char)System.in.read();
System.out.println("you typed"+ch);
System.in
returns an InputStream
. The method read()
without parameters "Reads the next byte of data from the input stream." according to the documentation.
System.in is basic reading in:
Scanner suckItUp=new Scanner(System.in);
System.out.println("Enter your favorite soda: ");
String name=suckItUp.nextLine();
System.in is the InputStream. It is usually connected the keyboard, but may also be connected to console.
Here's a nice link - Java IO tutorial
How to read a single char from the console in Java (as the user types it)?
How can I read input from the console using the Scanner class in Java?
Read up on this valuable topic. Java IO is super-important.
read()
is an instance method of the static variable named 'in
' of the System
class