Accepting input from keyboard: –

Accepting input from keyboard: –

  • In order to read the input from keyboard, inside system class variable such as ‘in’
  • So we represent keyboard as (
  • ( is also represented as InputStream object.
  • (System.out) is also represented as PrintStream object.
  • (System.err) is also represented as PrintStream object.
  • To read the value from keyboard, we create an object of InputStreamReader class. And inside the parenthesis of class name we have (
Ex: - InputStreamReader irr=new InputStreamReader(;
  • To read data property, we use BufferedReader class.
  • BufferedReader class has methods to read the data efficiently. So, the object of InputStreamReader must be passed inside the parenthesis of BufferedReader class.

Ex: –

BufferedReader br=new BufferedReader(new InputStreamReader(;
InputStreamReader isr=new InputStreamReader(;
BufferedReader br=new BufferedReader(isr);

Accepting character from keyboard: –

  1. To read a character in keyboard on monitor we use read() method of BufferedReader class.
  2. Read() method accept the value as ASCII integer byte.
  3. So, the integer value must be type casted explicitly into character type to store if into character type variable.

Comments are closed.

Create a website or blog at

Up ↑

%d bloggers like this: