How to enter quotes in a Java string?

后端 未结 10 1341
不知归路
不知归路 2020-11-22 05:38

I want to initialize a String in Java, but that string needs to include quotes; for example: \"ROM\". I tried doing:

String value = \" \"ROM\" \         


        
10条回答
  •  不知归路
    2020-11-22 06:13

    suppose ROM is string variable which equals "strval" you can simply do

    String value= " \" "+ROM+" \" ";
    

    it will be stored as

    value= " "strval" ";    
    

提交回复
热议问题