aspose file tools*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 56
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: 39544
    
  27
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 - updated with new look and Ping home screen widget
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36474
    
  16
And to add to what Ulf said, when Java was first developed, all Unicode characters occupied 16 bits = 2 bytes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why char type in java is is having 2 byte of memory?
 
Similar Threads
Data Types
Help in Final variables
question on unicode
Storing serialized objects
byte size of a string?