| Author |
I am wondering ...
|
Jagat Jyoti Das
Greenhorn
Joined: Jan 17, 2003
Posts: 1
|
|
I tried to compile and run this piece of code. The value of i remains the same even after I increment it . Please run the code to see the same. public class test{ public void test1(){ int i=1; System.out.println(i); i=i++; System.out.println(i); } public static void main(String[] args) { test k =new test(); k.test1(); System.out.println("Do you see something ??"); } }
|
 |
Valentin Crettaz
Gold Digger
Sheriff
Joined: Aug 26, 2001
Posts: 7610
|
|
This behavior is perfectly correct and has to do with the way the ++ operator works. Please see the following discussion about the ++ operator: http://www.coderanch.com/t/190825/java-programmer-SCJP/certification/Array
|
SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
|
 |
Prasad Kuppa
Ranch Hand
Joined: Apr 01, 2002
Posts: 151
|
|
Thanks Valentin. You have directed to very good thread. Where can I find list of these very good archived threads? Prasad
|
 |
Valentin Crettaz
Gold Digger
Sheriff
Joined: Aug 26, 2001
Posts: 7610
|
|
Try here: http://www.javaranch.com/maha/Discussions/discussions.html
|
 |
 |
|
|
subject: I am wondering ...
|
|
|