How to put quotation marks in a string in Java?

To put quotation marks in a string in Java, use the backslash escape character before the quotation mark like so: \".

Here's how you do it:

String myString = "\"Hello World!\"";

System.out.println(myString); // "Hello World!"