Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

A teaser  RSS feed

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What will be the output of the following code : and WHY ?
---------------------------------------------------------


[ Edited to include code tags - Paul Sturrock ]
[ November 08, 2006: Message edited by: Paul Sturrock ]
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to ask, is this homework?
 
Java Cowboy
Sheriff
Posts: 16083
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The output is 0.

Java method arguments are passed by value, and about "i = i++", see the FAQ: Post increment operator and assignment.

Both these issues are being discussed frequently in the Beginner and Intermediate forums here.
 
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not an advanced question. Moving...
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!