What is the range of the char type

The range of the char type is 0 to 2^16 - 1.

Showing Answers 1 - 2 of 2 Answers

Sumit Sengar

  • Aug 24th, 2005
 

char is unsigned so its minimum value is 0. It can't be negative.

  Was this answer useful?  Yes

In java, the range of a char type is
0 to 65535
or
0 to +((2^16)-1)
Getting java to print out the MIN_VALUE and max value is tricky because the characters at position 0 and 65535 are unprintable.  To remedy this cast the Character to an int.
System.out.println((int)Character.MIN_VALUE);
System.out.println((int)Character.MAX_VALUE);
//0
//65535

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Answer Question

Click here to Login / Register your free account


 
Send   Reset

 

Related Answered Questions

 

Related Open Questions