java菜鸟的问题~~~

来源:百度知道 编辑:UC知道 时间:2024/05/11 05:54:42
先看下这个:
String chi;
String result = null;
byte temp[];
---------------问题分割线------------------
temp = chi;
result = new String(temp);

问题:
把String赋给数组 是什么意义?
这两行代码是什么意思呀?
temp是字节数组
转换成字符串是什么涵义?

首先 这段代码有错误
temp = chi;
temp 是字节数组,而chi 是字符串, 不能这样赋值
这句 result = new String(temp);
是把temp字节数组作为参数传给String类,新建一个字符串对象,也就是把temp转化为字符串