Example:
String str1 = "Строка со "словом" в кавычках"; How to correctly insert a quote character (")?
Example:
String str1 = "Строка со "словом" в кавычках"; How to correctly insert a quote character (")?
final char dm = (char) 34; final String string = "STRING: " + dm + " string " + dm; System.out.println(string); Conclusion:
STRING: "string"
The most standard method used in many languages, including Java, is escaping with the \ character:
String myString = "Строка со \"словом\" в кавычках"; String str1 = "Строка со \"словом\" в кавычках"; Yes, there is, add before each character that you want to escape \ . For example, to display "C: \\\folder\\\folder1\" on the screen, add "screen" in front of each character like this:
System.out.println("\"C: \\\\\\\folder\\\\\\\folder1\\\\\""); String x = "\\"; String y = "\""; System.out.println("It's Windows path: " + y + "C:" + x + "Program Files" + x + "Java" + x + "jdk1.7.0" + x + "bin" + y); System.out.println("It's Java string: " + x + y + "C:" + x + x + "Program Files" + x + x + "Java" + x + x + "jdk1.7.0" + x + x + "bin" + x + y); Source: https://ru.stackoverflow.com/questions/413254/
All Articles