File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes I am wondering ... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "I am wondering ..." Watch "I am wondering ..." New topic
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I am wondering ...
 
Similar Threads
doubt on Thread join() and yield() method
Simple Doubt with Threads
thread EXAM WATCH from K&B
synchronized run()
Call to overloaded method with null reference