Java – why not always increase the operator’s work on chars?

Why

char c = 5;
int i = c++;

However, this causes a compiler error (invalid arguments / –) for the operator:

int i = argv[0].charAt(0)++;

Solution

Operators handle variables and expressions and return references to writable things instead of all general values In other words, there is no way to write the incremented char value back to the original string, so charat (0) is an error

You can solve this problem by converting argv [0] to a character array and incrementing the value in the array

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>