+ 1
string in java and python
public class Program { public static void main(String[] args) { System.out.println( 1 + '2' + 3 + '4'); } } OUTPUT 106
3 Réponses
+ 1
@Smriti Rastogi, I guess they are, probably, I'm no good with Java : ) anyways, it seems that when a number meets a double quoted string the number would be casted into string, and + sign concatenated the number (that had been casted as string) with double quoted string.
When a number meets single quoted string (char) the char will be treated as a number (based on its ASCII code) and + sign add the number with the ASCII number of the respective char. I hope my explanation here makes sense : )
Hth, cmiiw
+ 6
The '2' is interpreted by its ASCII value (50), and so is also '4', which is counted for as 52, so it actually sum 1 + 50 + 3 + 52 = 106
+ 1
single quoted string and doubly quoted list are treated differently....??