When the piece of code given below when executed in java and c++
gives different results in java and c++.

class Test
{
public static void main(String args[])
{
int a=2;
System.out.println("a " + a);
a=a++;
System.out.println("a " + a);
a=++a;
System.out.println("a " + a);
}
}

the Output when run in java is :
a2
a2
a3.

in c++ it is :
a2
a3
a4
----------------
Was this implementation intentional in java.If so whats the reason.


Mathi Ezhil
(India)