Question: ```
 saveBtnYes.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    saveBtnYesFunc(currentYesBtnId);
                    tempActivityList =activityNames;
                    return activityNames;
                }
            });

```

When I call the `saveBtnYesFunc` function, it returns an ArrayList value called `activityNames` to the onClick thread. I want to pass that value from inside of the `onClickListener` method to its parent method (this code is contained within another method). The last line of code `return activityNames` won't work. 

Is there any other way to do it?

Answer: 
This expression:

```
 C[i] = A[i++];

```

Invokes [undefined behavior](https://en.wikipedia.org/wiki/Undefined_behavior) because the variable `i` is both read and written without a sequence point.

While it is true that the right hand side of an assignment must be fully evaluated before it can be assigned to the left side, the evaluation of each subexpression is unsequenced, as is the side effect of `i` being incremented.

This is spelled out in section 6.5.16p3 of the [C standard](http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf) regarding the assignment operator:

> 
> An assignment operator stores a value in the object designated by the left operand. An
>  assignment expression has the value of the left operand after the assignment, but is not
>  an lvalue. The type of an assignment expression is the type the left operand would have
>  after lvalue conversion. **The side effect of updating the stored value of the left operand is
>  sequenced after the value computations of the left and right operands. The evaluations of
>  the operands are unsequenced.**
> 
> 
> 

In this specific example, the value of `i` could first be read to use as the index of `C`, then it could be read and written as part of the `i++` expression on the right side. Alternatively, `i++` could be evaluated first and incremented, and then `i` could be read to be used as the index of `C`.

The increment of `i` should be done as part of a separate statement to avoid this.

```
C[i] = A[i];
i++;

```
With dbush's response, I did a test using an additional variable to avoid the incidence and I got the expected result.

```
/* LOOP 2 */
i = 0;
int j = 0;
while (i < MYSIZE)
{
    C[j++] = A[i++];
}

```