#Is this wrong?

1 messages ยท Page 1 of 1 (latest)

light coyoteBOT
#

<@&987246883653156906> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question ๐Ÿค–. Maybe it helps! In any case, a human is on the way ๐Ÿ‘. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
Hey...I am practicing escape sequences in java. And ChatGPT keeps saying I am tripping. So. I want the output: "She says: "that's John's "favorite food." " " So I escaped it this way: String s = "She said: \" That's John's \"favorite\" food.\"\"" But C

Yes, the way you are trying to escape the double quotes in the desired output is incorrect. To achieve the desired output "She says: "that's John's "favorite food." ", you should escape the inner double quotes by preceding them with a backslash ().

Here is the correct way to do it:

System.out.println("She says: \"that's John's \"favorite food.\" ");

By adding a backslash before each inner double quote, you are telling Java to interpret them as part of the string literal and not as string delimiters. This will ensure that the output displays exactly as you intended.

broken imp
#

why do you put random " in the sttring ?

prisma jasper
#

nvm...I have to write my question from the start....my backslashes disappeared

#

ok, now

light coyoteBOT
#

Closed the thread.