Hi,
I am having a doubt that, What is the order of evaluation of equality operator. I feel it is from right to left. Please go through the below code,
1. int a[]={2,2};
2. int b=1;
3. a[b]=b=0;
System.out.println(a[0]);
System.out.println(a[1]);
Now at line 3, which array element value will be assigned to 0.
I got output as 2, 0. I expected 0,2.
In line 3, why a[b] is evaluated before b=0.
Please clarify my doubt.
Thanks,
I am having a doubt that, What is the order of evaluation of equality operator. I feel it is from right to left. Please go through the below code,
1. int a[]={2,2};
2. int b=1;
3. a[b]=b=0;
System.out.println(a[0]);
System.out.println(a[1]);
Now at line 3, which array element value will be assigned to 0.
I got output as 2, 0. I expected 0,2.
In line 3, why a[b] is evaluated before b=0.
Please clarify my doubt.
Thanks,