```
public class Solution {
public int minSubArrayLen(int s, int[] nums) {
if(0<nums.length){
Arrays.sort(nums);
int sum = 0;
int i = 0;
while(sum<s){
i++;
int x = nums.length-i;
sum += nums[x];
}
return i;
}
else return 0;
}
}
```

sum += nums[x];

generate ArrayIndexOutOfBoundsException