I'have doubt,if im asking wrong please correct me Question is
String s="hello";
String s1=' ';//error
String s2=s+' ';
I know line1 is correct and line 2 is wrong because we can initialize char a= ' ';
but am confused in line3 i read + operator in java can be used for concatenation with strings
but it accepts characters like ' ' what is the reason ?
s + 5, it's casted to String. For non-primitives,toString()will be calledsis aStringandaandbare integers, be careful with something likes + a + b. This is not the same ass + (a + b). The first one converts each integer to a string and appends the strings in turn. The second one adds the integers first.