示例代码如下所示

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);
    }
    
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2023-03-18
  • 2022-12-23
  • 2022-01-29
  • 2022-12-23
  • 2022-12-23
  • 2021-08-15
猜你喜欢
  • 2022-12-23
  • 2021-11-20
  • 2021-08-02
  • 2022-12-23
  • 2022-12-23
  • 2021-06-15
  • 2022-12-23
相关资源
相似解决方案