得到字符串的字节数

 public class LengthByte {
 public static void main(String[] args) {
  String str = "123abc试试看?";
  byte[] b = str.getBytes();
  System.out.println(str + "共包含" + b.length + "个字节");
 }
 
}

你可能感兴趣的:(String,Class,byte)