char newChar;
int amount = 2;
newChar = 'A' + 2; // gives me C, which is great
newChar = 'A' + amount; // nothing, i get an error ???
The error:
Incompatible types:
Required: char
Found: int
how can I make this work?
Printable View
char newChar;
int amount = 2;
newChar = 'A' + 2; // gives me C, which is great
newChar = 'A' + amount; // nothing, i get an error ???
The error:
Incompatible types:
Required: char
Found: int
how can I make this work?
Use castingCode:newChar = ( char ) ( ( int ) 'a' + amount ) ;