It's not a secret anymore!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes What does evaluation mean? post, pre ++ -- Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "What does evaluation mean? post, pre ++ --" Watch "What does evaluation mean? post, pre ++ --" New topic
Author

What does evaluation mean? post, pre ++ --

Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Hi,

Could anybody make me understand what does evaluation mean? It is said, the expression is first evaluated from left to right ... Is value is put at the time of evalution. Give a example please.
Little descriotion would be appreciated.


Thanks and Regargs,
cmbhatt


cmbhatt
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6657
    
    5

An opration like variable++ would change the value of the variable in the next line. An operation like ++variable will change the value of the variable immediately on the same line.

int x=0;
x++; - value of x is 1 in the next line
int y=0;
++y; - value of y is 1 here


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Thanks John,

Does next line increment also include the same line in postfix while there are sevaral post increment operaions like:

int x=1;
int y= x++ + x++ + ++x + x++;


Please clarify, how will the above expression be "evaluated"?

Thanks and Regards,
cmbhatt
chintan ramavat
Ranch Hand

Joined: Sep 15, 2006
Posts: 134
Its very important to make it clear

x = 3

y = x ++ ; // y = 3 ;
y = ++ x ; // y = 4 ;

value wont be incremented in the first expression but in the second it will be incremented first and then assigned to x.


hope it helped
chintan
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Chandra Bhatt:
...how will the above expression be "evaluated"?




"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
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Thanks Marc,

The way you answered was what I expected.




Thanks and Regards,
cmbhatt
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What does evaluation mean? post, pre ++ --
 
Similar Threads
Evaluation and Execution problem.
How to avoid getting bogus error messages when running a build file?
deactivate the evaluation language
SCEA part 3 results
postfix and prefix increment precedence in conditional expressions