循环之后的问题 [英] problem after for loop

查看:61
本文介绍了循环之后的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!!

这是我的for循环:

Shape [] shapes = new Shape [10];


for(int i = 0; i< shapes.length; i ++)

{

System.out.println(" \ n");

shapes [i] .printState();

area + = shapes [i] .area();
System.out.println(area );


}

我的问题是当我把System.out.println()放出for循环时它没有'不运行(不打印任何东西)。我不明白为什么这样做?我需要一些建议:)谢谢

解决方案

< blockquote class =post_quotes>
嗨!!

这是我的for循环:

Shape [] shapes = new Shape [10];


for(int i = 0; i< shapes.length; i ++)

{

System.out.println(" \ n");

shapes [i] .printState();

area + = shapes [i] .area();
System.out.println(area );


}

我的问题是当我把System.out.println()放出for循环时它没有'不跑(不打印什么)。我不明白为什么这样做?我需要一些建议:)谢谢



你的问题没有更多的背景就无法正确回答(代码

围绕您向我们展示的代码)。


''在哪里''区域''变量定义?这是编译运行吗?

展开 | 选择 | Wrap | 行号


展开 | 选择 | Wrap | Line数字


展开 | 选择 | Wrap | 行号


Hi !!
This is my for loop:
Shape[] shapes=new Shape[10];

for(int i=0;i<shapes.length;i++)
{
System.out.println("\n");
shapes[i].printState();
area+=shapes[i].area();
System.out.println(area);

}
My problem is that when i put the System.out.println() out of the for loop it doesn''t run( won''t print anything).I can''t understand why is doing it??I would need some advise :) thanks

解决方案

Hi !!
This is my for loop:
Shape[] shapes=new Shape[10];

for(int i=0;i<shapes.length;i++)
{
System.out.println("\n");
shapes[i].printState();
area+=shapes[i].area();
System.out.println(area);

}
My problem is that when i put the System.out.println() out of the for loop it doesn''t run( won''t print anything).I can''t understand why is doing it??I would need some advise :) thanks

Your question can''t be properly answered without a bit more context (code
around the code you''ve shown us).

Where is the ''area'' variable defined? Does this compile and run?

Expand|Select|Wrap|Line Numbers


Expand|Select|Wrap|Line Numbers


Expand|Select|Wrap|Line Numbers


这篇关于循环之后的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆