i get the error
`. java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:657)
at java.util.ArrayList.get(ArrayList.java:433)
at you.act(you.java:43)
at greenfoot.core.Simulation.actActor(Simulation.java:567)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:530)
at greenfoot.core.Simulation.runContent(Simulation.java:193)
at greenfoot.core.Simulation.run(Simulation.java:183)
when i try to run
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.util.List; import java.util.ArrayList; /** * Write a description of class you here. * * @author (your name) * @version (a version number or a date) */ public class you extends ProjectFEAR { int speed = 3 ; List sus; /** * Act - do whatever the you wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { if (Greenfoot. isKeyDown( "A" )) { setLocation(getX()-speed, getY()); } if (Greenfoot. isKeyDown( "D" )) { setLocation(getX()+speed, getY()); } if (Greenfoot. isKeyDown( "W" )) { setLocation(getX(), getY()-speed); } if (Greenfoot. isKeyDown( "S" )) { setLocation(getX(), getY()+speed); } if (isTouching(enemys. class )) { sus = getObjectsInRange( 20 , enemys. class ); sus.add(sus.get( 0 )); } } } |