Tried to store "\"the Dolphin\""
using this but it isn't working.
String s=""\"the Dolphin\""";
Tried to store "\"the Dolphin\""
using this but it isn't working.
String s=""\"the Dolphin\""";
Try this
String s="\"\\\"the Dolphin\\\"\"";
you have to escape special chars via \
"
and \
are special characters in String literal
"
is used to mark start or end of string \
is used to either
\t
or line breaks \n
\r
(and few others)\"
will let you use "
inside string (it will not represent end of string literal now so string like "hello\"world"
is valid)So if you want to create literals from special characters you need to escape them with \
. Same rule applies to \
itself so if you want to create string which will represent \
you need to write it as "\\"
(\
is escaped with another \
)
So try with "\"\\\"the Dolphin\\\"\""
String s = "\"\\\"the Dolphin\\\"\"";
// ↓ ↓ ↓↓↓↓↓↓↓↓↓↓↓↓ ↓ ↓ ↓
//literals: " \ "the Dolphin \ " "
//finally: "\"the Dolphin\""