java - Difference between apostrophe and backslash+apostrophe -


i don't understand difference between "'" , "\'". is,

public class test {     public static void main(string[] args) {          system.out.println("hello, i'm best!");         system.out.println("hello, i\'m best!");       } } 

gives same result:

hello, i'm best! hello, i'm best! 

is feature of language? or may there more complicated description? there same result on android?

for string literals, there no difference between ' , \'. character literals, in java enclosed ' characters, escape necessary.

'''   // not legal character literal ' '\''  // escaped character literal ' 

according jls, section 3.10.6, java escapes string , character literals, can use them in both cases. quoting jls link:

the character , string escape sequences allow representation of nongraphic characters single quote, double quote, , backslash characters in character literals (§3.10.4) , string literals (§3.10.5).

as far know, android uses java, expect same hold android well.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -