This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes questiion regarding varinble 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 "questiion regarding varinble" Watch "questiion regarding varinble" New topic
Author

questiion regarding varinble

varinder mahajan
Ranch Hand

Joined: Jun 11, 2008
Posts: 47
public class a
{
public static void main(String str[])
{
int a=10;
a=a++;
System.out.println("a:"+a);
}
}

it out puts 10 why?
[ July 30, 2008: Message edited by: varinder mahajan ]

Beat the world,if you can.......
Sid Murrey
Ranch Hand

Joined: Jul 07, 2008
Posts: 58
Well, it turns out that the Java postfix operator behaves in a weird way.
Check out http://www.rizzoweb.com/java/postfixIncrement.html
This was the fifth result in a google search for "postfix increment operator" by the way ;-)

Cheers,
Sid
[ July 30, 2008: Message edited by: Sid Murrey ]
 
GeeCON Prague 2014
 
subject: questiion regarding varinble