Blogs Blogs

Escape Sequence Blogs

Newest Most Active

When creating output from a Java program, you can control where line breaks occur in the text that you output by using the println method, which puts a line break at the end of whatever text is being output by the call.   However, you may need to insert line breaks into strings that you are creating, such as in the toString method of a class. How do you do it?   First, note that when creating String literals, you can insert a variety of special characters using escape sequences.   An escape sequence is a sequence of characters, starting with a backslash ("\"). When the reader that is constructing your string encounters a backslash, it checks the subsequent character(s), and interprets the sequence as instructions to insert a specific character described by the sequence.    For example, since string constants are delimited by double quote characters, if you want to embed a double quote character in a string... read more

Escape Sequence Blogs RSS feed