若让我实现的话,我可能这么实现 package net.csdn.xdj.model.d050403;import java.io.*;/** * <p>读</p> * <p>Title: community.csnd.net</p> * <p>Description: java问题解答</p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: 自由人</p> * @author 许德建(simonxuluo) * @version 1.0 */ public class MyInput { public MyInput() { } public static int readInt() { byte[] bs = new byte[12]; int length = 0; int result = 0; try { length = System.in.read(bs); result = Integer.parseInt(new String(bs,0,length).replaceAll("[\r]|[\n]","")); } catch (Exception ex) { System.out.println("int: value("+Integer.MIN_VALUE+","+Integer.MAX_VALUE+")"); } return result; } }
好久不来了,我这样实现了package mypackage.io;import java.io.*;public class MyInput { //Read a string from the keyboard public static String readString() { BufferedReader br = new BufferedReader(new InputStreamReader(System.in),1);
package net.csdn.xdj.model.d050403;import java.io.*;/**
* <p>读</p>
* <p>Title: community.csnd.net</p>
* <p>Description: java问题解答</p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: 自由人</p>
* @author 许德建(simonxuluo)
* @version 1.0
*/
public class MyInput {
public MyInput() {
} public static int readInt() {
byte[] bs = new byte[12];
int length = 0;
int result = 0;
try {
length = System.in.read(bs);
result = Integer.parseInt(new String(bs,0,length).replaceAll("[\r]|[\n]",""));
}
catch (Exception ex) {
System.out.println("int: value("+Integer.MIN_VALUE+","+Integer.MAX_VALUE+")");
}
return result;
}
}
{
//Read a string from the keyboard
public static String readString()
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in),1);
String string = "";
try
{
string = br.readLine();
}
catch(IOException ex)
{
System.out.print(ex);
}
return string;
}
public static int readInt()
{
return Integer.parseInt(readString());
}
public static double readDouble()
{
return Double.parseDouble(readString());
}
}请问simonxuluo(爱江山更爱美人) ,你用的是什么IDE呢,我只会用JC