dp[i] represents the max sum of sub array from some 'j' (j<i) to 'i', including 'i'

```
public int maxSubArray(int[] nums) {
int max = nums[0];
int[] dp = new int[nums.length];
for (int i = 0; i < nums.length; i++) {
dp[i] = (i == 0 || dp[i - 1] <= 0) ? nums[i] : dp[i - 1] + nums[i];
max = dp[i] > max ? dp[i] : max;
}
return max;
}
```