When printing out text there are some characters that cannot be printed directly because they have a special meaning. These characters are ", ' and \ . In order to print these characters you need to put a forward slash ion front of them to print out.
g.drawString("Mrs. Noss' pet", 50,50); // will give an error
g.drawString("Mrs. Noss\' pet", 50,50); // will give Mrs. Noss' pet at 50,50
Other escape sequences used to format output are:
\n - new line
\t = tab
The escape squences in the Java Subset are:
\n, \\ and \" . The \' is only necessary inside the character literals and is not in the subset.