DataInputStream in = new DataInputStream(new BufferedInputStream(System.in)); String as = in.readLine(); String bs = in.readLine(); int a = new Integer(as).intValue(); int b = new Integer(bs).intValue(); System.out.print(a + " " + b);
printr("%d",a+b);应该是用System.out.println()代替! scanf()函数你可以借鉴一下下面的这个程序 public class Test{ public Test(){}
public static void main(String[] args){
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //在新版本的JDK里,DataInputStream的readLine()方法已经不推荐了,所以用了BufferedReader String s;
String as = in.readLine();
String bs = in.readLine();
int a = new Integer(as).intValue();
int b = new Integer(bs).intValue();
System.out.print(a + " " + b);
scanf()函数你可以借鉴一下下面的这个程序
public class Test{
public Test(){}
public static void main(String[] args){
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//在新版本的JDK里,DataInputStream的readLine()方法已经不推荐了,所以用了BufferedReader
String s;
try{
while ((s = br.readLine()).length() != 0)
System.out.println(s);
}catch(IOException ioe){
ioe.printStackTrace();
}
}
}
String a=input.readLine();
try{
int int_a=Integer(a).value();
}catch(Exception e){//error}