The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
November 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Incremental Operator query

Posted by Muruganandam on November 12, 2000 at 10:57 AM

thanks for your answer but still I am not very clear just take a case like
a=1;
b= a++;
SOP b;
SOP a;

here I can get an answer b = 1 and a=2. My query is not the first a. why the second a is also printed as 1 while the a is supposed to increase itself.

i agree the first step would be
a=a
then the right hand side a has to increase by 1 and when it comes to the next step it should be 2.

hope my doubt is genuine

Muruganandam


> > class test3
> > {
> > public static void main(String s[])
> > {
> > int a = 1;
> > System.out.println(a);
> > a=a++;
> > System.out.println(a);
> >
> > a=a++;
> > a=a++;
> > System.out.println(a);
> > int b=a++;
System.out.println(a);
System.out.println(b);
> > }
> > }





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us