Escape sequences

If you spend a lot of time working with strings though, I anticipate that you're going to run into a common problem. Let's take a look at it quickly. I'm just going to write a brand new program here. I'm going to declare a string, then I'm going to have our program print the string to the screen. But the value I'm going to assign to this string is going to be a little tricky. I'd like our program to print out The program says: "Hello World" (I'd like Hello World to be surrounded by double quotation marks):

The problem here is that putting double quotation marks inside a string literal confuses Java as shown in the preceding ...

Get Java Programming for Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.