读入的当然是Ascii码
char如何置空?置空是什么意思,不就是初始化0吗?
字符串是一个非常重要的概念

解决方案 »

  1.   

    a[] = null;//置空
    字符串操作,在什么语言中都重要。JC pro有不用注册的下载。楼主找找。最好还是学习使用IDE工具
      

  2.   

    http://www.allimant.org/javadoc/jdk14e.html
      

  3.   

    我把你的程序稍作改动,你看看注释。另外,字符串是非常常用的一种数组类型,当然是非常重要的。import java.io.IOException;public class my1 {
        public static void main(String[] args) {
            char a[] = new char[50];
            int i, j, tottl = 0;
            char max = 0;
            System.out.println("please enter how many number you will enter:");
            try {
                // 这是为了取得输入的数字的值(用ASCII码减去'0'的ASCII码
                tottl = (int) System.in.read() - 48;
                
                // 这是为了把输入的多余的字符读完 
                while (System.in.available() > 0) {
                    //System.out.println(System.in.read());
                    System.in.read();
                }
            } catch (IOException e) {
                System.err.print(e.toString());
            }        System.out.println("tottl is " + tottl);
            // 因为i是从0开始的,那么应该于tottl - 1结束
            //for (i = 0; i <= tottl; i++) {
            for (i = 0; i < tottl; ++i) {
                try {
                    a[i] = (char) System.in.read();
                } catch (IOException e) {
                    System.err.print(e.toString());
                }
                System.out.println(a[i]);
                if (a[i] > max)
                    max = a[i];
            }
            System.out.println("the max is " + max);
        }
    }
      

  4.   

    这样读取就好了
    -----------------------------------      
    BufferedReader stdin =
       new BufferedReader(
       new InputStreamReader(System.in));
    String s = new String();
    s = stdin.readLine();
    tottl = Integer.parseInt(s);
      

  5.   

    请问什么是IDE工具啊?
    为什么tottl=(int)System.in.read();
    读入的是个ASCII码呢?
      

  6.   

    System.in 是一个 InputStream,InputStream 的 read() 方法返回一个 int 值,这个 int 值就是读入的字符的 ASCII,如果你需要字符直接 char ch = System.in.read() 就可以取得字符 (也可以加 (char) 强制转换)。