Is it possible to add data to a string after adding “\0” (null)?

后端 未结 4 1902
故里飘歌
故里飘歌 2020-12-18 01:16

I have a string that I am creating, and I need to add multiple \"\\0\" (null) characters to the string. Between each null character, is other text data (Just ASCII alphanume

4条回答
  •  执念已碎
    2020-12-18 02:06

    This is because \ is an escape character in Java (as in many C-related languages) and you need to escape it using additional \ as follows.

    String str="\\0Java language";
    System.out.println(str);
    

    and you should be able the display \0Java language on the console.

提交回复
热议问题