Thursday, April 26, 2007

Core Java Programming

      
       Core java seems very difficult now a days....

Check out the following statements

        int i=1;
        i+=i++;
        System.out.println(i);

What do you think is the output of the above statements..
It is just a simple assignment and increment statement.

in i++
            i gets incremented only after the execution of the line,
so i=1+1
            so i =2 in second line
but in the third line the value of i should be incremented but as per the execution of the statement,
Value of i is got as 2
What happened to the increment.....

=+ and ++ cant execute in the same statement and same variable

Why????

2 comments:

Pegasus said...

why do u call it core java....
its a simple common programming which is language agnostic

Jesintha said...

oh......
I knew it with java programming only...............