The unary plus operator performs an automatic conversion to int
when the type of its operand is byte
, char
, or short
. This is called unary numeric promotion, and it enables you to do things like the following:
char c = 'c';
int i = +c;
Granted, it's of limited use. But it does have a purpose. See the specification, specifically sections §15.15.3 and §5.6.1.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…