• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

questiion regarding varinble

 
varinder mahajan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Sid Murrey
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic