posted 23 years ago
Please suggest the following if I compile undermentioned 3 sets separetly :
int a=5;
Set1:
// Here at first println statement, the val. of a is 5, agreed�
// And the second println prints 6, agreed �
System.out.println("val of a :"+(a++)); // o/p=5
System.out.println("val of a :"+(a)); // o/p=6
Set2:
// Here val. of a is incremented first and assigned to
// variable a.I agree �
// And the second println prints 6, agreed �
System.out.println("val of a :"+(a=++a)); // o/p=6
System.out.println("val of a :"+(a)); // o/p=6
Set3:
// Here at first println statement, the val. of a is 5
// the same is assigned
// to variable a, but why incrementation doesn't take
// place after that.
// i.e second println should print 6 as a's value but
// o/p is 5 , Pl suggest.
System.out.println("val of a :"+(a=a++)); // o/p=5
System.out.println("val of a :"+(a)); // o/p=5
Thanks,
Vikas s.