The idea is simply. The product basically is calculated using the numbers before the current number and the numbers after the current number. Thus, we can scan the array twice. First, we calcuate the running product of the part before the current number. Second, we calculate the running product of the part after the current number through scanning from the end of the array.

```
public class Solution {
public int[] productExceptSelf(int[] nums) {
int leng = nums.length;
int[] ret = new int[leng];
if(leng == 0)
return ret;
int runningprefix = 1;
for(int i = 0; i < leng; i++){
ret[i] = runningprefix;
runningprefix*= nums[i];
}
int runningsufix = 1;
for(int i = leng -1; i >= 0; i--){
ret[i] *= runningsufix;
runningsufix *= nums[i];
}
return ret;
}
```

}