aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes I am wondering ... Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply 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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: I am wondering ...
 
Similar Threads
synchronized run()
thread EXAM WATCH from K&B
doubt on Thread join() and yield() method
Simple Doubt with Threads
Call to overloaded method with null reference