GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes Why char type in java is is having 2 byte of memory? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Why char type in java is is having 2 byte of memory?" Watch "Why char type in java is is having 2 byte of memory?" New topic
Author

Why char type in java is is having 2 byte of memory?

Bhavesh Sangwan
Ranch Hand

Joined: Aug 08, 2012
Posts: 57
I mean prior to java, all programming languages were using only 1 byte of memory for CHAR datatype. Then why java offered 2 bytes..?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42039
    
  64
Prior to Java, no programming language supported Unicode easily; Java does, thus allowing you to handle text in most of this planet's languages and scripts without much work on your part. Pretty cool, huh?


Ping & DNS - my free Android networking tools app
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39072
    
  23
And to add to what Ulf said, when Java was first developed, all Unicode characters occupied 16 bits = 2 bytes.
 
GeeCON Prague 2014
 
subject: Why char type in java is is having 2 byte of memory?