March 2019
Intermediate to advanced
242 pages
6h 21m
English
Imagine what happens when the letter combination represented by an escape sequence (let's say, \n) must be included as a part of the string value. Let's modify our example, as follows:
<HTML>
<BODY>
<H1>\n - new line, \t - tab</H1>
</BODY>
</HTML>
In this case, you can escape the \n sequence by using another backslash, as follows:
String html = "<HTML>" +
"\n\t" + "<BODY>" +
"\n\t\t" + "<H1>\\n - new line, \\t - tab</H1>" +
"\n\t" + "</BODY>" +
"\n" + "</HTML>";
But, with the changes, it's getting difficult to read and understand the preceding code. Imagine a developer in your team writes such code. Let's see how you could make it more readable.
As a workaround, you can define String ...
Read now
Unlock full access