I want to initialize a String in Java, but that string needs to include quotes; for example: \"ROM\"
. I tried doing:
String value = \" \"ROM\" \
suppose ROM is string variable which equals "strval" you can simply do
String value= " \" "+ROM+" \" ";
it will be stored as
value= " "strval" ";
Not sure what language you're using (you didn't specify), but you should be able to "escape" the quotation mark character with a backslash: "\"ROM\""
In Java, you can escape quotes with \
:
String value = " \"ROM\" ";
Look into this one ... call from anywhere you want.
public String setdoubleQuote(String myText) {
String quoteText = "";
if (!myText.isEmpty()) {
quoteText = "\"" + myText + "\"";
}
return quoteText;
}
apply double quotes to non empty dynamic string. Hope this is helpful.