Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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 Android Security Essentials Live Lessons this week in the Android 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: 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: 41155
    
  45
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: 38075
    
  22
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
byte size of a string?
Data Types
question on unicode
Help in Final variables
Storing serialized objects