如题,String类型内部是char数组构成的,一个char占2个字节,也就是byte[2],但是,字符串转化成byte数字其实只有对应字符转化成数组的一半,这是为什么?public static void main(String[] args) { String str = "a"; System.out.println(str.getBytes().length); }打印的是1,不是应该是2吗?
添加回答
举报
0/150
提交
取消