Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

question

Thread view: 
parwal.sandeep@gmail.com - 17 Feb 2006 05:00 GMT
hello grp !!!
  i've one question plz excuse if it is silly to ask !!

public static void main( String[] args )
{
    int i=10;
     i = i++;
     SOP (i);
}

why it is printing  10 instead of 11 ??
Roedy Green - 17 Feb 2006 05:17 GMT
>      i = i++;
>      SOP (i);
>}
>
>why it is printing  10 instead of 11 ??

because you are tormenting the compiler with deliberately ambiguous
code.  It would require  the JLS and a language lawyer to figure out
what is supposed to happen. Don't do that. There is never any need for
goofy code like that.

write simply
i++;

SOP is presumably a method not a class, so it should be called sop.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Knute Johnson - 17 Feb 2006 06:13 GMT
> SOP is presumably a method not a class, so it should be called sop.

Secret code for System.out.println :-).

Signature

Knute Johnson
email s/nospam/knute/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.