当n=0时,sum=0,&&后面的就不会执行了,直接返回sum=0
public class Solution { public int Sum_Solution(int n) { int sum=n; //n=1时直接返回1 boolean flag=(sum>0)&&((sum+=Sum_Solution(n-1))>0); return sum; } }
public class Solution { public int Sum_Solution(int n) { int sum=n; //n=1时直接返回1 boolean flag=(sum>0)&&((sum+=Sum_Solution(n-1))>0); return sum; } }