I want to know that when i=10 and k=0 then and when i am trying to print the value of i when i am doing like this :
case 1 : i = i++;
It's printing i=10 where
case 2 : k = i++;
It's printing i = 11;
I want to know how exactly doing this operation? because in both cases i++ is doing and after then i am printing the value of i?
if in the second case i am getting i=11; then i should get 11 in case 1 also. Please someone explain me the process?
The Code is like this :
public class Case1{
public static void main(String[] a){
int i = 10;
i = i++;
System.out.println(i);
}
}
It's giving ans : 10;
and
public class Case1{
public static void main(String[] a){
int i = 10;
int k = 0;
k = i++;
System.out.println(i);
}
}
Here the ans is coming as 11.
Now please explain me both the cases like how it's doing in the first program i = 10 and in second program 11 as ans.