This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes '0'  and 0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark " Watch " New topic
Author

'0' and 0

Jennifer Wallace
Ranch Hand

Joined: Nov 30, 2001
Posts: 102
char c='0';
char i=0;
System.out.println(Integer.toHexString(c));//30
System.out.println(Integer.toHexString(i));//0
if (c!=i)
System.out.println(c+" is not equal to "+i);
// 0 is not equal to 0
why is that here in a regular System.out.println statement the output doesn't differentiate between two different values (0x30 and 0x00)?
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Jennifer,
You might have a bug in your runnable code. The example that you typed in above works correctly. The last println prints out:
0 is not equal to
with the last value being a space (0 = space character).
The following will show you it easier.

Regards,
Manfred.
Jennifer Wallace
Ranch Hand

Joined: Nov 30, 2001
Posts: 102
U are right! Output's just fine! Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: '0' and 0
 
Similar Threads
Java Character Declaration Format
Cannot understand the output...
Url encoding in GET request
String conversion
int array default value