String temp = "我";
int aa = temp.getBytes().length;System.out.println("length = " + aa);aa = 2
不知道你是不是这个意思??

解决方案 »

  1.   

    如果是下面这一串,会输出什么呢?String temp = "我们是中国人";
    int aa = temp.getBytes().length;System.out.println("length = " + aa);aa = 2
    不知道你是不是这个意思??
      

  2.   

    String str = "子定义";
    if (str.length() == str.getBytes().length)
       System.out.println("单字节");
    else if (str.length() * 2 == str.getBytes().length)
       System.out.println("双字节");
      

  3.   

    String temp = "我们是中国人";
    int aa = temp.getBytes().length;System.out.println("length = " + aa);aa = 12