Java中的int和char算术

时间:2018-12-10 16:38:31

标签: java char int

我想知道为什么在Java中有些工作,而有些却没有。最后一个出现“必需的字符,发现int”错误。

int n = 5;
char c = 'A'; //works ok
c++; //works ok
c += n; //works ok
c += 5 - n; //works ok
c = 15 + 65; //works ok
c = 5 + n; //doesn't work
c = c + 1; //doesn't work

0 个答案:

没有答案