```
public int[] productExceptSelf(int[] nums) {
int[] result = new int[nums.length];
int size = nums.length;
for(int i = 0; i < size; i++) {
result[i] = 1;
}
for(int i = 1; i < size; i++) {
result[i] = result[i-1]*nums[i-1];
}
int tmp = nums[size-1];
for(int i = size - 2; i >= 0; i--) {
result[i] *= tmp;
tmp *= nums[i];
}
return result;
}
```