Use special character in the java code
Print double quotation inside the println statement
------------------------------------------------------------------
We use " " to print something in java.
For example:-
System.out.println("I am Sandeep Kumar Mishra");
But what if we want to use the special character " in the statement it self.
e.g.
System.out.println("I loved "math" in my school days");
Now you must be thinking there will be a conflict. Definitely, there is conflict.
So the way to make it correct is as follows
use
System.out.println("I loved \"math\" in my school days");
instead of
System.out.println("I loved "math" in my school days");
Refer the output in the following screen:-
#Print double quotation inside the println statement
#print special character in java
#print double quotation inside the println statement
#how to write " " inside System.out.println
------------------------------------------------------------------
We use " " to print something in java.
For example:-
System.out.println("I am Sandeep Kumar Mishra");
But what if we want to use the special character " in the statement it self.
e.g.
System.out.println("I loved "math" in my school days");
Now you must be thinking there will be a conflict. Definitely, there is conflict.
So the way to make it correct is as follows
use
System.out.println("I loved \"math\" in my school days");
instead of
System.out.println("I loved "math" in my school days");
Refer the output in the following screen:-
#Print double quotation inside the println statement
#print special character in java
#print double quotation inside the println statement
#how to write " " inside System.out.println
Comments
Post a Comment