Question:
How can you add quotes inside a String?
Answer:
Just escape the quotes:
String value = "\"hello\"";
Code:
public class Quotes { public static void main(String[] args) { // add " to string String str1 = "\"test quotes\""; // add ' to string String str2 = "\'test quotes\'"; System.out.println(str1); System.out.println(str2); } }
Output:
$ java Quotes "test quotes" 'test quotes'