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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply 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: 97
why sun microsystem given a character has a 2bytes capacity.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3047
    
    1

How many bytes would you use?
Ritesh raushan
Ranch Hand

Joined: Aug 29, 2012
Posts: 97
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: 4747
    
    7

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?
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3047
    
    1

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: 97
thanks stephen.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: why char data of two bytes.
 
Similar Threads
Comparison between BEA, IBM & Oracle for 2+ J2ee
WSAD or RAD with jwsdp2.0
HFE page 567-5
Why does Groovy have this name?
jsp:useBean doubt