Quotes mark where text begins and ends — the quotes themselves are not printed. Everything inside is printed exactly: every letter, space, and symbol.
System.out.println("Hello"); // Hello System.out.println("2 + 3"); // 2 + 3 (text, not 5) System.out.println("a b"); // a b (spaces kept)
Java does not compute what is inside the quotes — "2 + 3" prints as text.
"2 + 3"
▶ Try it: run this, then change something and run it again.
What does System.out.println("Hello"); print?
System.out.println("Hello");
What does System.out.println("2 + 3"); print?
System.out.println("2 + 3");
Type exactly what this prints:
System.out.println("Java is fun");
Which line prints exactly cat dog (with a space)?
cat dog
System.out.println("Hi!");