Integer.parseInt把String转成int后再加

解决方案 »

  1.   

    System.in.read()只能读取一个字符的ascii值,用readline就可以了
      

  2.   

    我试过了,需要改成这样,这么复杂?
    char和String有什么关系?
    void ModifyStudentAge () {
            char c=' ';
            prt("请输入要加的年龄数:");
            try{ 
    c=(char)System.in.read(); 
               }catch(IOException e){};
    StudentAge=Integer.parseInt(Character.toString(c))+StudentAge;
    }
    }
      

  3.   

    BufferedReader stdin = new  BufferedReader(new InputStreamReader(System.in));
    int StudentAge=Integer.parseInt(stdin.readLine());
      

  4.   

    char是一个字符
    String是字符串,由0或者多个字符组成,在程序中存储和处理方式都是不一样的