• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

problem with increment operator.

 
Ranch Hand
Posts: 74
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Guys,

here i have a question regarding increment operator , code is bellow


in the above code i'm trying to increment the value of x , at the first sop(x) is good ,but at x=x++ here is also ok because here is the post increment so it first assign the value and then increment ..here my
doubt is that...
when i print through sop(x) then it again print 11 as output but what happened with corresponding post incremented value of x which should be 12 logically..but sopln() is unable to get it why???
so please i would like to know about this ....how ??

hopefully, waiting for your reply.

regards:
vivek
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vivek Bhardwaj wrote:when i print through sop(x) then it again print 11 as output but what happened with corresponding post incremented value of x which should be 12 logically..but sopln() is unable to get it why???


It got lost. You need to go back to:
x = x++;
What do you think that does?

Winston
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We also have an article on this : PostIncrementOperatorAndAssignment
 
viki Bhardwaj
Ranch Hand
Posts: 74
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Seetharaman Venkatasamy wrote:We also have an article on this : PostIncrementOperatorAndAssignment



Thanks! Seetharaman for sharing the valuable link ,...it was good enough explanation.
 
Do you pee on your compost? Does this tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic