My java code, last executed input is 0.000001, 2147483647. Runtime error. Anyone can help?

```
public double pow(double x, int n) {
double[] array1 = new double[Math.abs(n)];
for (int i = 0; i<Math.abs(n); i++){
if (i==0)
array1[i] = x;
else
array1[i] =array1[i-1]*x;
}
if(n==0)
return 1;
if(n>0)
return array1[array1.length-1];
else
return 1.0/array1[array1.length-1];
}
```