0

how to print "3 2 4 5 1" (including " )

i am facing error while i m printing " quotes

3rd May 2021, 4:06 AM
Sachin Saxena
Sachin Saxena - avatar
6 Antworten
+ 1
if you are trying to print a quote, you need to use the escape characher, its usually the backslash character \ you would print it like so: System.out.println("\"3 2 4 5 1\"") notice the \" , these are meant to escape the quote character to be treated as one in the string.
3rd May 2021, 4:21 AM
Apollo-Roboto
Apollo-Roboto - avatar
+ 1
recommended to Learn about escape sequences.
3rd May 2021, 4:41 AM
Ayush Kumar
Ayush Kumar - avatar
+ 1
Try using backslash before double quotes...
3rd May 2021, 5:35 AM
A. R. Singh
+ 1
Calvin Thomas this past was tagged in java and single quotes wont work in this language. It does work in python, javascript and some other. Even in these languages, escape sequence are important to learn in case you need to print a mix of them.
3rd May 2021, 1:07 PM
Apollo-Roboto
Apollo-Roboto - avatar
+ 1
Apollo-Roboto Thanks for the correction. I usually don't bother to check the tags. I've edited my comment.
3rd May 2021, 2:16 PM
Calvin Thomas
Calvin Thomas - avatar
0
An easier approach: print('"3 2 4 4 1"') # Here, I've used single quotes so that # double quotes are allowed without # escaping them with a backslash Edit: Works in Python, not sure of other languages.
3rd May 2021, 5:46 AM
Calvin Thomas
Calvin Thomas - avatar