• Register
0 votes
43 views
I want to initialize a String in Java, but that string needs to include quotes; for example, I was thinking it is easy to put these ” ” into another double quote. But that is a wrong procedure because  will be using two pair of double quotes and the message will lie in between these which will show an error, the compiler will think that my statement ends at second quote.

 

System.out.print(“”  hello world “”  ); 

how to solve this problem?

10 7 2
6,050 points

1 Answer

0 votes
Hence to print double quotes along with our message we will use an escape character ( \ ) goes by the name of backslash character, before the inside double quote. 
This will tell the compiler to escape a character.

You can try like this :
System.out.print(” \”hello world \” “);

 

11 6 4
34,930 points

Related questions

0 votes
1 answer 5 views
5 views
I am finding difficulty with non repeated characters in a string in Java.
asked Sep 26 Daniel Anderson 4k points
0 votes
1 answer 7 views
7 views
I need to know how to remove the first cgaracter of a string in Java.
asked Sep 25 Daniel Anderson 4k points
0 votes
1 answer 2 views
2 views
I need to know how to print duplicate characters from string in Java.
asked Oct 3 Daniel Anderson 4k points
0 votes
1 answer 7 views
7 views
I am finding the answers in several blog for removing particular character from string in java.
asked Sep 29 Daniel Anderson 4k points
0 votes
1 answer 5 views
5 views
I need to know how to extract numbers from alphanumeric string in Java.
asked Sep 26 Daniel Anderson 4k points