Home  |   STIU  |   WOW  |   SCJP  |   SCDJWS   |   JEE FAQ  |   About US  |  

FAQ
  Java FAQ
  JSP FAQ
  Servlet FAQ
 

Advertisement

XyzWs Java FAQ:
What is valid value range for char?


Printer-friendly version Printer-friendly version | Send this 
article to a friend Mail this to a friend


Previous Next vertical dots separating previous/next from contents/index/pdf Contents
Advertisement
XyzWs Java FAQ : What is valid value range for char?

What is valid value range for char?


A char supports a 16-bit unicode character and is unsigned 2 byte integer. It can be assigned directly to an integer value but the integer value must be in its value range or you would get a compiler error.

The largest number it can hold is 216 which is 65535. The following value ranges are equivalent to represent the value range of char:

0 to 216-1dec
0 to 65535dec
00 to 0177777octal
0x0 to 0xFFFFhex
0000 0000 0000 0000 to 1111 1111 1111 1111binary
'\u0000' to '\uFFFF'unicode

Any numeric assignment to a char could be cast to a char and get past the compiler in this case the char will only contain the right two bytes.


Previous Next vertical dots separating previous/next from contents/index/pdf Contents

Support  | Feedback  | Help