Hi I have a piece of Java code that shifts a character by 2, like so
char ch = 'A';
ch += 2;
System.out.println(ch);
The output in this case is 'C' (as expected). But if I rewrite the code like this:
char ch = 'A';
ch = ch + 2;
System.out.println(ch);
I get a compilation error 'Type mismatch: cannot convert from int to char'. Why is this happening, aren't the two assingments equal?