Redian新闻
>
java 可不可以反复定义一个数组
avatar
java 可不可以反复定义一个数组# Java - 爪哇娇娃
e*r
1
First create: Activity[] temp = new Activity[100];
after finishing using that temp array, I want create another temp array
for the following purpose.
while(temp.length>0)
that is I want repeatedly to check above condition in while loop, while
each time the contents in temp array are different.
Thanks
avatar
c*t
2
no problem

【在 e******r 的大作中提到】
: First create: Activity[] temp = new Activity[100];
: after finishing using that temp array, I want create another temp array
: for the following purpose.
: while(temp.length>0)
: that is I want repeatedly to check above condition in while loop, while
: each time the contents in temp array are different.
: Thanks

avatar
g*g
3
No problem, but not recommended, most of time it would be anti-pattern.
Maybe ArrayList will fit your usage better.

【在 e******r 的大作中提到】
: First create: Activity[] temp = new Activity[100];
: after finishing using that temp array, I want create another temp array
: for the following purpose.
: while(temp.length>0)
: that is I want repeatedly to check above condition in while loop, while
: each time the contents in temp array are different.
: Thanks

avatar
A*o
4
And since you redefine it every time,
look out for null pointer.

array
while

【在 g*****g 的大作中提到】
: No problem, but not recommended, most of time it would be anti-pattern.
: Maybe ArrayList will fit your usage better.

avatar
m*t
5
I know it's probably just different terminology, but I just could't help --
you can _reassign_ an array, but you can't _redefine_ it, not with the same
scope.

while

【在 e******r 的大作中提到】
: First create: Activity[] temp = new Activity[100];
: after finishing using that temp array, I want create another temp array
: for the following purpose.
: while(temp.length>0)
: that is I want repeatedly to check above condition in while loop, while
: each time the contents in temp array are different.
: Thanks

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。