Can the char type be categorized as an integer?

前端 未结 8 2597
盖世英雄少女心
盖世英雄少女心 2020-12-01 22:32

Just now I read \"char is the only unsigned integral primitive type in Java.\" Does this mean the char is one of the integral types in Java?

Same as in C, recently I

8条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-01 23:07

    Yes a char type can be categorized as an integer:

    int i = 49;
    int k = 36;
    
    System.out.print((char)i + (char)k + "$"); //may expect 1$ but print: 85$
    

提交回复
热议问题