This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Bhavesh Sangwan
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42967
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Campbell Ritchie
Sheriff
Posts: 48394
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And to add to what Ulf said, when Java was first developed, all Unicode characters occupied 16 bits = 2 bytes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic