Reputation: 718
So a googler asked this question, as what are the different ways you can represent a character (in this case the double quote) in JAVA.
One being
String t ="\\u0022";
What are the other ways ?
Upvotes: 2
Views: 474
Reputation: 201447
In Java, one can escape literal quotes like
String t = "\"";
and with the unicode escape you already gave (with another literal \
because the unicode conversion happens very early in the compilation phase)
String t = "\\u0022";
and you can promote a character like
String t = Character.toString('"');
Upvotes: 2
Reputation: 1002
The two other way are:
\"
,\u0022
,new Character('"').toString();
.The first one is the simplest, and easiest on the programmer, the second is longer, and generally harder to remember, and the third is easy to remember but generally illogical.
Upvotes: 0