public int sum (int num1, int num2){
int sum = 0;
if(num2>num1){
for (int i = num1; i<=num2; i++){
sum = sum + i;
}
}
else{
for (int i = num2; i <= num1; i++){
sum = sum + i;
}
}
System.out.println("The sum between " +num1+ " and " +num2+ " equals " + sum);
return sum(num1, num2);
}
}
无限循环问题。任何修复?试图找到两个输入之间所有数字的总和。这是类定义有什么想法吗?