As experimented, using ternary operator (a>b?a:b) is much faster than If statement and Math.max(a,b) function.

```
public int maxSubArray(int[] nums) {
int currentMax = nums[0];
int finalMax = currentMax;
for (int i = 1; i < nums.length; i++) {
currentMax = Math.max(nums[i] + currentMax, nums[i]);
finalMax = Math.max(currentMax, finalMax);
}
return finalMax;
}
```