Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Bhavesh Sangwan
Ranch Hand
Posts: 62
  • 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: 42970
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: 54034
130
  • 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
Boost this thread!