```
public class Solution {
public boolean canJump(int[] nums) {
int i = 0;
int length = nums.length;
int max = nums[0];
while(i<length){
max = Math.max(nums[i], max);
if(max == 0 && i<length-1) return false;
max--;
i++;
}
return true;
}
}
```