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