java - 如何为此编写一个名为 product 的实例方法?(评论有说明)
问题描述
// An instance method named product, which
// multiplies the values between min and max and
// returns the result. For example, if min = 6
// and max = 9, then this should return 3024
// (6 * 7 * 8 * 9). If min is greater than
// max, then this should return 1.
public int product() {
int runningTotal = 1;
for(int i = min; i < max + 1; i++) {
runningTotal += i;
}
return runningTotal;
}
解决方案
推荐阅读
- java - 有没有办法访问以前创建的 Guice 注射器?
- android - 为什么从绑定列表中删除对象后,Xamarin 中 ListView 上的项目不会消失,即使 ItemSource 属性已重置?
- python - 如何使用 Python 恢复标点符号?
- flutter - 如何在 Flutter Shader 中做从 topLeft 到 bottomRgiht 的渐变效果?
- ruby-on-rails - 我不想通过 alias_method 修改的模型类的未定义方法
- microsoft-graph-api - Microsoft Graph - 使用 sendMail API 时电子邮件传递失败
- c++ - 为什么在这种情况下我需要 .template
- angular - 数据集未在 html 中显示
- c - FR_DISK_ERROR 总是由 f_open 返回
- docker - 将 php/nginx docker 容器连接到外部 mysql