Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Breeze Zhang
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Breeze,
Here is the article that helps a lot:
maha's solution
[ June 05, 2003: Message edited by: Claire Yang ]
 
Breeze Zhang
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you!
But they don't explain why JVM is different from C compilation.and for what reason?
 
La Vish
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check here
If you need more information just use google
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic