March 2019
Intermediate to advanced
242 pages
6h 21m
English
The following code is an example of XML data that you might need to store using a Java string:
<plastic id="98751">
<singleuse>
<item value="Water Bottle" replaceWith="Steel bottle" />
<item value="Straw" replaceWith="Ban Straws" />
<item value="spoon" replaceWith="Steel Spoon" />
</singleuse>
</plastic>
The following code shows how you can define the preceding data as a String literal by using the appropriate escape sequences:
String data =
"<plastic id=\"98751\">\n" +
"<singleuse>\n" +
"<item value=\"Water Bottle\" replaceWith=\"Steel bottle\" />\n" +
"<item value=\"Straw\" replaceWith=\"Ban Straws\" />\n" +
"<item value=\"spoon\" replaceWith=\"Steel Spoon\" />\n" +
"</singleuse>\n" +
"</plastic>";
Again, the escape sequences ...
Read now
Unlock full access