Write a program to accept or read a character from keyboard during execution of program?

import java.io.*; public class ReadChar {                 public static void main(String arg[]) throws IOException                 {                                 BufferedReader br=new BufferedReader(new InputStreamReader(System.in));                                 System.out.print("Enter a Character : ");                                 char ch=(char)br.read();                                 System.out.println("The Character Is : "+ch);                 } }

Advertisements

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 (System.in) (System.in) 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... Continue Reading →

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: