I just wanted to add a bit to rgettman's answer.
As he said, in this context there is no difference between ' and \' . In the case of the backslash, ' is executed, although this is not practical, since in this situation there is no need to escape (the compiler can distinguish the contents from the shell without help).
If you tried to use ' as a char, that would be important. For instance:
char c = '''; //compile error char c = '\'';
The same goes for escaping the double quote in a String declaration. For instance:
String s = """; //compile error String s = "\"";
Essentially, escaping a character tells the compiler to treat the character as content, because otherwise it would terminate the shell, and the compiler thinks that there is an erroneous character at the end of your line.
Now, to tie everything together, this works great:
String s = "'"; char c = '"';
And that’s because the compiler doesn’t have a problem with the ' from " difference to finish the case. Hopefully this fixes some screening issues for others.
source share