java输入和输出

来源:百度知道 编辑:UC知道 时间:2024/05/15 11:34:19
请大哥给小弟写个从键盘输入个1然后显示我要打印的东西比如
我爱中国,谢谢各位大哥了

也就是先按你的要求写了个,看下下吧
import java.io.*;
public class T1 {
public static void main(String[]args){
String s="";
System.out.println("Input a number !");
BufferedReader b=new BufferedReader(new InputStreamReader(System.in));
try{
s=b.readLine();
}catch(IOException e){
e.printStackTrace();
}
if(Integer.parseInt(s)==1)
System.out.println("我爱中国!");
else
System.out.println("不是 1 哦?");

}

}