请问一段java代码中的一句话的意思

来源:百度知道 编辑:UC知道 时间:2024/09/22 14:27:23
import java.awt.*;
import java.awt.event.*;
public class Bird extends Thread{
private int xdir=2*(1-2*(int)Math.round(Math.random()));
private int ydir=2*(1-2*(int)Math.round(Math.random()));
private boolean running=false;
private Cage cage=null;
protected int x,y;
Image bird=Toolkit.getDefaultToolkit().getImage("sfz.jpg");
public Bird(Cage _cage,int _x,int _y)
{cage=_cage;
x=_x;
y=_y;
start();
}
public void start()
{running=true;
super.start();
}
public void halt(){
running=false;
}
public void run(){
while(running)
{
move();
try{
sleep(120);
}catch(InterruptedException ie){
System.err.println("Thread interrupted");
}
cage.repaint();
}
}
private void move(){
x+=xdir;
y+=ydir;
if(x>cage.getSize().width){
x=cage

if (birds[i]!=null)

(如果birds数组里的元素birds[i]引用的对象不等于null)为true的话
......

1楼已经说了

这是一个比较简单的画图问题,birds[]是你定义的一个Bird类型的数组,,而bird[i]!=null其实很容易理解,就是判断bird[i]是否为空,也许你在别的地方理解有一些偏差,在好好看看。加油!