参考代码class Demo { public static void main(String[] args) { //字符串转byte数组 String s1 ="学习Java"; byte[] bts = s1.getBytes(); //byte数组转字符串 String str = new String(bts); System.out.println(str); }}输出学习Java