Win a copy of Functional Reactive Programming this week in the Other Languages 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
Posts: 42968
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
Pie
Posts: 50235
79
  • 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