java代码~(找不出来错误了~求教~谢谢)

[复制链接]
查看11 | 回复3 | 2012-11-1 13:29:26 | 显示全部楼层 |阅读模式
没有错,但是没有输出。你不是不是忘了把代码写在方法里了? public class test {public static void main(String[] args){int index = 0;int[] array = new int[1000];for(int i = 0; i < 1000; i++){ if(i % 4 == 0) { array[index] = i; index++; }}System.out.println(index); } } 我新建了一个叫test的类,跑完输出index是250...
回复

使用道具 举报

千问 | 2012-11-1 13:29:26 | 显示全部楼层
int index = 0;int[] array = new int[1000];for (int i = 0; i <array.length; i++) { if (i % 4 == 0) {
array[index] = i;
index++; }}System.out.printl...
回复

使用道具 举报

千问 | 2012-11-1 13:29:26 | 显示全部楼层
你这段代码要达到什么目的?这一段纯粹从语法上来说是没有错误的,但可能是你程序逻辑上的问题吧。...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行