简体   繁体   English

如何使用Java接受键盘输入?

[英]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. 我想在一行中接受来自键盘的整数和字符类型输入。

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);  
     }  
    }  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM