java - Quote marks when concatenating string with a single character -


what kind of quote marks should choose single character when concatenate string?

string s1="string"; 

should use

string s2=s1+'c'; 

or

string s2=s1+"c"; 

?

you can use both! give try!

"why?" ask. magic here + operator.

when + used strings, automatically turns other operand string! that's why can used 'c', character literal. can used "c" because of course, "c" string literal.

not that, can add integers string:

string s2=s1+1; 

Comments

Popular posts from this blog

php - trouble displaying mysqli database results in correct order -

depending on nth recurrence of job in control M -

sql server - Cannot query correctly (MSSQL - PHP - JSON) -