aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Problem in println Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Problem in println" Watch "Problem in println" New topic
Author

Problem in println

rock stone
Greenhorn

Joined: Jul 19, 2007
Posts: 3
Hi
please check the code below, i'm unable to understand that how that 2nd println is producing an output of 38.
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
Howdy Rock!

Welcome to the Ranch!




The second line adds an int + a char + an int.

This is no String concat. The char is converted to an int, and since the output is 38,
I guess that
char x = 38-4-2;
the x should be a char.



Yours,
Bu.


all events occur in real time
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Burkhard Hassel:
...I guess that
char x = 38-4-2;
the x should be a char...

Indeed, the space char has a decimal value of 32. So 4 + ' ' + 2 evaluates as 4 + 32 + 2.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Problem in println
 
Similar Threads
increment post and pre, when used in println
Increment & Assignment
Calendar Class (Wrong month! )
Array Question
String.split() method functionality