aspose file tools
The moose likes Beginning Java and the fly likes why char data of two bytes. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "why char data of two bytes." Watch "why char data of two bytes." New topic
Author

why char data of two bytes.

Ritesh raushan
Ranch Hand

Joined: Aug 29, 2012
Posts: 100
why sun microsystem given a character has a 2bytes capacity.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3883
    
  18

How many bytes would you use?


The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Ritesh raushan
Ranch Hand

Joined: Aug 29, 2012
Posts: 100
Stephan van Hulst wrote:How many bytes would you use?



char takes one byte for each character then why he given char as a 2 bytes.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8661
    
  23

Ritesh raushan wrote:char takes one byte for each character...

Says who? You've plainly discovered that in Java, it doesn't.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3883
    
  18

If a character was only one byte, you could have no more than 256 characters. The latin alphabet alone uses 24 letters and 10 digits. What about all the other languages with their alphabets and special letters and symbols? There is no way you can represent them all with only one byte.

With two bytes, you can represent 65.536 characters. This seems much more adequate.
Ritesh raushan
Ranch Hand

Joined: Aug 29, 2012
Posts: 100
thanks stephen.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why char data of two bytes.
 
jQuery in Action, 3rd edition