Core Java: char arithmetic promotes to int before the result is cast back

Arithmetic on char operands promotes both to int, so 'A' + 'B' produces an int, not a char; getting a char result back requires an explicit cast.

Code
char c = 'A';
char next = (char) (c + 1);
int sum = 'A' + 'B';
System.out.println("'A' + 1 as char = " + next);
System.out.println("'A' + 'B' as int = " + sum);
Output
'A' + 1 as char = B
'A' + 'B' as int = 131
Advertisement
More in JAVA

Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.

Published 2026-09-27

© Java Coding Hub · About · Contact · Privacy · Terms