Originally posted by Veena Point:
Char is neither a primitive numeric type nor it is String object.Then how the above expression is valid?
char IS a primitive type. In addition, it is also a numeric type (byte, short, int, long). So what you are doing is not a concatination but simple addition.
Further, since 'a' and 'b' are constants and the summation fits into a char, the compiler is allowing you to assign the sum to a char without a cast. But try this:
char a = 'a';
char b = 'b';
char c = a + b;
Then try this:
char ch1 = '\uFFF0'+'\u000f';
char ch2 = '\uFFF0'+'\u000f';
ch2++;
char ch3 = '\uFFF0'+'\u001f';<== ??
System.out.println((int)ch1);
System.out.println((int)ch2);
What will be the output?
Have fun