This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons 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: 3599
    
  14

How many bytes would you use?
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: 7551
    
  18

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: 3599
    
  14

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.
 
Similar Threads
jsp:useBean doubt
Comparison between BEA, IBM & Oracle for 2+ J2ee
WSAD or RAD with jwsdp2.0
HFE page 567-5
Why does Groovy have this name?