I want to print inverted quotes in java. But how to print it?
for(int i=0;i<hello.length;i++) {
String s=hello[i].toLowerCase().trim();
System.out.println(""+s+"");
}
expected OP: "hi".....
\" - escape sequence Since printf uses ""(double quotes) to identify starting and ending point of a message, we need to use \" escape sequence to print the double quotes.
to show double quote you can simple use escape character("\") to show it.
Because double quotes delimit String values, naturally you must escape them to code a literal double quote, however you can do it without escaping like this:
System.out.println('"' + s + '"');
Here, the double quote characters ("
) have been coded as char
values. I find this style easier and cleaner to read than the "clumsy" backslashing approach. However, this approach may only be used when a single character constant is being appended, because a 'char' is (of course) exactly one character.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With