Kunal Choudhary wrote:char x='a';
x=x+1;
The result of any mathematical operation where both operands are byte, char, short or int is always of type int.
In this case:
x: char
1: int
x + 1: int
There are three ways to solve this:
The first explicitly casts the int result back to a char, whereas the increment operators have an implicit casting internally.