```
public class Solution {
public int singleNumber(int[] nums) {
Arrays.sort(nums);
int size = nums.length;
int index1 = 0;
int index2 = 1;
if (size ==1){return nums[0];}
while (index1<size-1){
if (nums[index1] != nums[index2]){break; }
index1 +=2;
index2 +=2;
}
return nums[index1];
}
}
```