为什么这个循环没有在执行

amanda2333 2017-12-11 03:49:40
什么都没有打出来啊
package progress;


import java.util.Scanner;

public class text {

public static void main(String[] args) {
// TODO Auto-generated method stub
int[]arr = {186, 186, 150 ,200 ,160, 130, 197 ,200};
int[] count = new int[arr.length];
Arrays.fill(count, 0);
int max = arr[arr.length - 1];

for(int i = 0;i> arr.length;i++) {
if(arr[i] < max) {
count[i] = count[i + 1] + 1 ;
System.out.println(max);
}

else {
count[i] = count[i + 1] ;
max = arr[i];
System.out.println(max);
}
}
}
public static int[] SortDe(int[] arr) {
int[] count = new int[arr.length];
Arrays.fill(count, 0);
int max = arr[arr.length - 1];

for(int i = arr.length - 2;i<= 0;i--) {
if(arr[i] < max) {
count[i] = count[i + 1] + 1 ;
System.out.println(max);
}

else {
count[i] = count[i + 1] ;
max = arr[i];
System.out.println(max);
}
}
return count;
}
}



...全文
198 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
迟到_啦 2017-12-12
  • 打赏
  • 举报
回复
楼上全部正确,for循环进不去就不会输出了
BigDecimal二爷 2017-12-11
  • 打赏
  • 举报
回复
同上,for循环,条件语句i>arr.length错了,应该是i<arr.length
Braska 2017-12-11
  • 打赏
  • 举报
回复
循环条件写错了。 应该是i<arr.length; 而且,循环体count[i+1]这样写会数组越界吧。
  • 打赏
  • 举报
回复
main方法里的for循环,判断条件:int i=0;i>arr.length;i++,这里就错了,是i<arr.length。。。。

62,612

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧