Skip to content

Commit bdd6b71

Browse files
committed
feat: Use escape sequences to print double quotes in strings [quote-escape]
🔑 Key: quote-escape 🧠 Logic: - To include double quotes (`"`) within a string in Java, use the escape character (`\"`). - Example: ➤ `"She said, \"Hello!\""` → prints: She said, "Hello!" ➤ `"This string contains \"quotes\"."` → prints: This string contains "quotes". 📘 Purpose: - Useful for formatting dialogue, JSON strings, or quoted output in terminals and files. - Prevents syntax errors that occur when raw quotes are misinterpreted as string boundaries. Signed-off-by: Somesh diwan <[email protected]>
1 parent 7109c26 commit bdd6b71

File tree

1 file changed

+6
-0
lines changed
  • JDK Features/Escape Sequences in Java/src

1 file changed

+6
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
public class Code4 {
2+
public static void main(String[] args) {
3+
System.out.println("She said, \"Hello!\"");
4+
System.out.println("This string contains \"quotes\"."); //Quotes within a string
5+
}
6+
}

0 commit comments

Comments
 (0)