File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 3371
    
    9
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: 7052
    
  16

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?
Artlicles by Winston can be found here
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3371
    
    9
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: why char data of two bytes.
 
Similar Threads
HFE page 567-5
Why does Groovy have this name?
jsp:useBean doubt
WSAD or RAD with jwsdp2.0
Comparison between BEA, IBM & Oracle for 2+ J2ee