Why does the Java char primitive take up 2 bytes of memory?

后端 未结 7 728
有刺的猬
有刺的猬 2020-11-30 03:38

Is there any reason why Java char primitive data type is 2 bytes unlike C which is 1 byte?

Thanks

7条回答
  •  一生所求
    2020-11-30 04:32

    char in Java is UTF-16 encoded, which requires a minimum of 16-bits of storage for each character.

提交回复
热议问题