Double quotes (" ..") work but 2 single quotes(the single quote symbol used twice for start and end) dont work (''..'')?


#1



Replace this line with your code.


#3

@rithvikkranti

Difference between double quotes and single quotes

Single quote

We need to be careful while putting apostrophes

// example of bad code
'hello how you're doing'

So you will need to put backslash

// example of good code
'hello how you\'re doing'

Double quotes

All normal

"hello how you're doing"

#4

Double quotes (” ..”) work but 2 single quotes(the single quote symbol used twice for start and end) dont work (”..”)?

If you meant, could you use two singles instead of one double, then the answer is "No".

''This is a string'' // don't do this

#5

ok i got that.
but can you explain me how this will work?

// example of good code
'hello how you\'re doing'

Here , single quote is used.
I thought single quote is used only for char


#6

In Java, yes, use singles only for chars, use doubles for strings.


#7

And Ruby is even a bit more tricky, decomposing single quoted strings into single characters in lieu of the special ones.