aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes why?a=a++ the result value of a is different between java and c 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 "why?a=a++ the result value of a is different between java and c" Watch "why?a=a++ the result value of a is different between java and c" New topic
Author

why?a=a++ the result value of a is different between java and c

Breeze Zhang
Greenhorn

Joined: May 28, 2003
Posts: 5
if
a = 1;
a = a++;
then, at the next line:
java: a -> "1":
c: a -> "2"
I think their sequences of process this code is different, but why?
does java compile engine change this for some good?
Claire Yang
Ranch Hand

Joined: Aug 30, 2002
Posts: 57
Hi, Breeze,
Here is the article that helps a lot:
maha's solution
[ June 05, 2003: Message edited by: Claire Yang ]
Breeze Zhang
Greenhorn

Joined: May 28, 2003
Posts: 5
thank you!
But they don't explain why JVM is different from C compilation.and for what reason?
La Vish
Ranch Hand

Joined: Apr 17, 2002
Posts: 161
check here
If you need more information just use google


La Vish
SCJP 1.4, President 60s Club
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
There is no specific requirement in the C programming language for the result of x = x++; Although it works one way on most compilers, it may work differently on others. In Java, the statement always works the same way on all compilers.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
 
 
subject: why?a=a++ the result value of a is different between java and c