论坛: 编程破解 标题: 请问?JAVA的输入怎么弄呀? 复制本贴地址    
作者: mousejiji [mousejiji]    论坛用户   登录
请问各位JAVA的输入怎么弄呀?
例如: 我要从键盘输入一个int型的数
用:int month;
month=System.in.read();
不行
又用:byte month;
month=System.in.read();
不行
又用:byte month;
month=System.in.read(month);
不行
又用:int month;
month=InputStream.readInt();
还是不行
又用:
InputStreamReader reader=new InputStreamReader(System.in);
BufferedReader input=new BufferReader(reader);
String months=input.readline();
int month=Integer.parseInt(months);
还是不行
编译都不能通过。
各位帮帮忙,到底怎么弄呀?


[此贴被 mousejiji(mousejiji) 在 09月21日16时59分 编辑过]

地主 发表时间: 09/21 16:19

回复: 286 [unique]   版主   登录
import java.io.*;

public class inputoutput
{
public static void main(String[] args)
{
String s;
InputStreamReader ir=new InputStreamReader(System.in);
BufferedReader in =new BufferedReader(ir);

try{
s=in.readLine();
while (s!=null)
{
System.out.println(s);
s=in.readLine();
}
in.close();
}catch(IOException e)
                    {
                    e.printStackTrace(); 
                      }
}
}

B1层 发表时间: 09/22 15:46

回复: kenter1643 [kenter1643]   论坛用户   登录
286可以加上注释吗???

B2层 发表时间: 10/02 11:37

回复: xibaige [xibaige]   论坛用户   登录
    学JAVA的加我,,大家一起讨论。。QQ187129558


[此贴被 xibaige(xibaige) 在 10月03日14时55分 编辑过]

B3层 发表时间: 10/03 14:42

论坛: 编程破解

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号