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

后端 未结 7 772
有刺的猬
有刺的猬 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

    Java used as a internationalize so, its work in different languages and need to space more than one byte, that's why its take 2byte of space in char. for eg the chinese language can't hanfle one byte of char.

提交回复
热议问题