user5608145
user5608145

Reputation:

How to Accept Input from the Keyboard using Java?

I want this Syntax Except Scanner.I know Scanner Works good for this program.

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter USN:");
String usn=br.readLine();

I want to accept both integer and character type input from the keyboard in a single line.

Upvotes: 0

Views: 1635

Answers (1)

amit prasad
amit prasad

Reputation: 556

Run this code

import java.io.*;  
    class G5{  
    public static void main(String args[])throws Exception{  

    InputStreamReader r=new InputStreamReader(System.in);  
    BufferedReader br=new BufferedReader(r);  

    System.out.println("Enter your name");  
    String name=br.readLine();  
    System.out.println("Welcome "+name);  
     }  
    }  

Upvotes: 2

Related Questions