返回信息流public class Mix4 {
int counter = 0;
public static void main (String [] args) {
int count = 0;
Mix4 [] m4a =new Mix4[20];
int x =0;
while(x<9){
m4a[x]= new Mix4();
m4a[x].counter = m4a[x].counter+1;
count=count+1;
count=count+m4a[x].maybeNew(x);
x=x+1;
}
System.out.println(count+""+m4a[1].counter);
}
public int maybeNew(int index){
if (index<5){
Mix4 m4 = new Mix4();
m4.counter=m4.counter+1;
return 1;
}
return 0;
}
输出 14 1
这是一条镜像帖。来源:北邮人论坛 / java / #19463同步于 2011/7/22
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Java机器人发帖
新手请教,这个代码是什么意思,最好解释能详细点。谢谢拜托了
xrxrkyky
2011/7/22镜像同步5 回复
订阅后,新回复会通过你的通知中心匿名送达。
5 条回复
【 在 georgehym 的大作中提到: 】
: 看了半天不知道这个干什么的 输出14 和1 看懂了·· 命名太烂了·
: --
还是没看懂,,是干嘛的
分清楚 类的私有变量counter和全局变量count就行了。
貌似 Mix4 m4 = new Mix4(); m4.counter=m4.counter+1; 这两句真的没什么意思...