0
how to print "3 2 4 5 1" (including " )
i am facing error while i m printing " quotes
6 Réponses
+ 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.
+ 1
recommended to Learn about escape sequences.
+ 1
Try using backslash before double quotes...
+ 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.
+ 1
Apollo-Roboto Thanks for the correction. I usually don't bother to check the tags. I've edited my comment.
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.