解决方案 »

  1.   

    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package test;/**
     *
     * @author Administrator
     */
    public class Test {    /**
         * @param args
         */
        public static void main(String[] args) {
            char[] charArray = {'1', 'e', ' ', '@', '3', ' ', 'F'};
            int zimu = 0, shuzi = 0, kong = 0, other = 0;
            for (int i = 0; i<charArray.length; i++) {
                if ((charArray[i] >= 'a' || charArray[i] >= 'A') && (charArray[i] <= 'z' || charArray[i] <= 'Z')) {
                    zimu++;
                } else if (charArray[i] >= '0' && charArray[i] <= '9') {
                    shuzi++;
                } else if (charArray[i] == ' ') {
                    kong++;
                } else {
                    other++;
                }
            }
            System.out.println("字母个数为:"+zimu);
        }}
      

  2.   

    你这里for循环的条件是什么意思?for(int i=0;charArray[i]!='\0';i++)你定义的字符字符数组里面没有0,这个循环已经是个死循环了.如果是要遍历数组的全部元素可以这样写for (int i = 0; i < charArray.length; i++)
      

  3.   


    +1楼主,java的字符串没有'\0'这个概念