【发布时间】:2014-06-18 14:45:41
【问题描述】:
我试图弄清楚这个练习太久了,但我被困在这里。我需要编写一个布尔方法,它将数组作为参数,如果数组中的数字按降序排列,则应返回 true。 Bu 任何时候我尝试我都有相同的价值或错误。这是我的代码:
public class Question1c{
public static void main (String[] args){
int[] arr = {1, 9, 3, 4, 5, 6};
boolean product = isDecreasing(arr);
System.out.println(product);
}
public static boolean isDecreasing (int[] numbers){
int first = numbers[0];
for (int i : numbers){
if(first <= i){
first = i;
return true;
}
//else{
// return false;
//}
}return false;
}
}
【问题讨论】:
-
你得到了什么错误?
标签: java arrays methods boolean