Just Began: Help needed with Arrays

I am just learning java, and would appreciate help for the problem below:
Given an array of ints, swap the first and last elements in the array. Return the modified array. The array length will be at least 1.
Here is my solution, which does not work:
public int[] swapEnds(int[] nums) {
int[] answer;
answer = new int[nums.length];
answer = nums;
answer[answer.length - 1] = nums[0];
answer[0] = nums[nums.length - 1];
return answer;
}
I cannot make the end of nums display as the beginning of int[] answer, it seems to be like a recessive gene, not showing up if answer[answer.length - 1] = nums[0]; is there.

Looks like answer and nums refer to the same array. So answer[0] is the same memory location as nums[0].
Perhaps you should use a temp variable to save the value being moved to keep it from being overwritten.
Also add some println() statements to show the values you are working with. For example:
System.out.println("nums[0]=" + nums[0] + ", answer[0]=" + answer[0]);

Looks like answer and nums refer to the same array. So answer[0] is the same memory location as nums[0].
Perhaps you should use a temp variable to save the value being moved to keep it from being overwritten.
Also add some println() statements to show the values you are working with. For example:
System.out.println("nums[0]=" + nums[0] + ", answer[0]=" + answer[0]);

Yeah, okay.
I stored nums[0] and nums[nums.length - 1] in separate variables before initiating answer as nums, that seemed to work. Thanks.