哪位高手给我讲道JAVA很简单

来源:百度知道 编辑:UC知道 时间:2024/06/22 01:23:07
class Test
{
public static void main(String[] args)
{
int[] a= {3, 5, 7, 9};
for(int i=1;i<4;i++)

a[0]+=a[1];
System.out.println(a[0]);

}
}
讲下过程 多谢!!!
程序是没有问题的 我试过了

我给你调整了下格式,写了下注释,希望对你有用:
public class Test{ //类名
public static void main(String[] args){ //mian函数
int[] a= {3, 5, 7, 9}; //定义数组a
for(int i=1;i<4;i++){ //循环3次
a[0]+=a[1]; //相当于 a[0]=a[0]+a[1]
}
System.out.println(a[0]); //输出18(3+5+5+5)
}
}
有疑问发信息我

程序有问题。完毕

...没分,,,,,,,没人回答的,,,,,,,,,,,,,,,