Quotation marks inside a string [duplicate]
Solution 1:
String name = "\"john\"";
You have to escape the second pair of quotation marks using the \ character in front. It might be worth looking at this link, which explains in some detail.
Other scenario where you set variable:
String name2 = "\""+name+"\"";
Sequence in console:
> String name = "\"john\"";
> name
""john""
> String name2 = "\""+name+"\"";
> name2
"""john"""
Solution 2:
You need to escape the quotation marks:
String name = "\"john\"";
Solution 3:
You can add escaped double quotes like this: String name = "\"john\"";