示例代码如下所示
public class test {
public static void main(final String[] args) {
String s="Hello world!";
System.out.println(s);
//字符串转换为字节数组
byte []a=s.getBytes();
for(int i=0;i<a.length;i++)
{
System.out.print(a[i]+" ");
}
System.out.println(s);
//字节数组转换为字符串
String str=new String(a);
System.out.println(str);
}
}