posted 15 years ago
hello jaya,
u see u must understand three steps to identify whether the
given number is valid hex number or not,
1. it must begin with 0x OR 0X.
2. it can have digits and numbers 1,2,3,4,5,6,7,8,9,a,b,c,d,e,f
3. each number in a hex number represents corresponding four digits in
binary format of the given number i.e.
for example consider the number 0x8eda which in binary format becomes
8 e d a
1000 1110 1101 1010
so u see by this we come to know whether the number is exceeding the 16
bits assigned for char literal.we can also find the value of the hex number easily.
one more point when using th 0xYYYY format we can have less than 4 digits or numbers but when we use unicode representation we must have four numbers or digits i.e.
'\u00a' ---> invalid
'\ucafe' ---> valid
0x00a ----> valid
0xcafe ---> valid
according to me to find whether a number is valid octal number or not there are 2 steps
1. number should start with 0.
2. number must have only digits and that too only 0,1,2,3,4,5,6,7
SCJP 1.4<br /><a href="http://www.geocities.com/sunjava4u" target="_blank" rel="nofollow">SUN JAVA 4 U</a>- links and resources for SCJP aspirants