M
Mausam
Hello,
http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#101089
defines escape character for single character as well.
But single quote works fine in String without any escape character.
public class Class1 {
private static String str = "I have a single quote. That's it";
private static String str1 = "I have a single quote. That\'s it";
public static void main(String[] args) {
System.out.println(str);
System.out.println(str1);
}
}
How the two string is different? And when should I use escape
character for single quote?
http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#101089
defines escape character for single character as well.
But single quote works fine in String without any escape character.
public class Class1 {
private static String str = "I have a single quote. That's it";
private static String str1 = "I have a single quote. That\'s it";
public static void main(String[] args) {
System.out.println(str);
System.out.println(str1);
}
}
How the two string is different? And when should I use escape
character for single quote?