KeyboardInput 类你写了吗?这个类是要自己写的,不然就不会成功运行

解决方案 »

  1.   

    KeyboardInput的类不能在类库中调用吗?怎么写呀?
      

  2.   

    import java.io.*;
    public class KeyboardInput {
    private final BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
    public final synchronized int readInteger(){
    String input="";
    int value=0;
    try{
    input=in.readLine();
    }catch(IOException e){}
    if(input!=null){
    try{
    value=Integer.parseInt(input);
    }catch(NumberFormatException e){}
    }
    return value;
    }
    public final synchronized long readLong(){
    String input="";
    long value=0L;
    try{
    input=in.readLine();
    }catch(IOException e){}
    if (input!=null){
    try{
    value=Long.parseLong(input);
    }catch(NumberFormatException e){}
    }
    return value;
    }
    public final synchronized double readDouble(){
    String input="";
    double value=0.0D;
    try{
    input=in.readLine();
    }catch(IOException e){}
    if(input!=null){
    try{
    value=Double.parseDouble(input);
    }catch(NumberFormatException e){}
    }
    return value;
    }
    public final synchronized float readFloat(){
    String input="";
    float value=0.0F;
    try{
    input=in.readLine();
    }catch(IOException e){}
    if(input!=null){
    try{
    value=Float.parseFloat(input);
    }catch(NumberFormatException e){}
    }
    return value;
    }
    public final synchronized char readCharacter(){
    char c=' ';
    try{
    c=(char)in.read();
    }catch(IOException e){}
    return c;
    }
    public final synchronized String readString(){
    String s="";
    try{
    s=in.readLine();
    }catch(IOException e){}
    if(s==null){
    s="";
    }
    return s;
    }
    }
    你在试试看能不能运行。
      

  3.   

    如果还报错误,你就把public final synchronized int readInteger();
                       public final synchronized long readLong();
                       public final synchronized double readDouble();
                       public final synchronized float readFloat();
                       public final synchronized char readCharacter();
                       public final synchronized String readString();
    里面的final 去掉,就ok了。因为声明为final 的函数只能在本类中调用。