Is it possible to add this symbol " to a String
or print to console?
I'm using it for my ImageIcon
! file path thanks!
Asked
Active
Viewed 1.4k times
0

Andrew Thompson
- 168,117
- 40
- 217
- 433

Scorpiorian83
- 469
- 1
- 4
- 17
-
3Down voters care to share a reason? Even if naive, this is a simple and direct question. If 'lack of research' is the reason, try finding a duplicate on SO. Even with `[java] [string] escape` I was not seeing obvious hits on the first page of results. And note of course that **`escape`** in that search was 90% of the answer. – Andrew Thompson Jul 21 '14 at 11:36
-
@AndrewThompson Thanks Andrew I did use quite a reasonable amount of time researching for it but I am a newbie and I seriously can't find anything which helps. Cheers. :) – Scorpiorian83 Jul 21 '14 at 11:40
-
3I don't doubt it for a moment. Anything involving `"` is difficult to search/research! Google ignores it completely. – Andrew Thompson Jul 21 '14 at 11:41
-
Too lazy to search............ – alex2410 Jul 21 '14 at 11:51
6 Answers
8
Yes, you need to escape the character with \
for Java to understand it:
String quote = "\"";

Andrew Stubbs
- 4,322
- 3
- 29
- 48
-
thanks oh by the way, where can i find information about this symbol stuff? :) – Scorpiorian83 Jul 21 '14 at 11:37
-
3The first official source I can find is: http://docs.oracle.com/javase/tutorial/java/data/characters.html – Andrew Stubbs Jul 21 '14 at 11:39
2
To be able to include " in a Java String you need to escape it like this
String s = "this is a String containing \" which is escaped by backslash"

user264230
- 630
- 3
- 7
- 19
1
Another way that was not mentioned here is the use of a char object.
String quote1 = (char)'"';
String quote2 = (char)34;

ByteBit
- 333
- 1
- 9
0
Did you mean How to print "Hello World" text on console? If yes then you can do that like this:
System.out.print("\"Hello World\"");

Andrew Thompson
- 168,117
- 40
- 217
- 433

NullPointer
- 152
- 1
- 16