How do I make Java wait for a method to finish before continuing?
问题 So my problem is that I need these methods to run one after another but I cannot work out how to make the methods wait before being run. Any help is appreciated. Thank you. Here is my code: public void startMoving() throws InterruptedException { moveEnemy("right",3); wait(); moveEnemy("down",3); wait(); moveEnemy("right",2); wait(); moveEnemy("up",1); wait(); moveEnemy("right",2); wait(); moveEnemy("up",2); wait(); moveEnemy("right",2); wait(); moveEnemy("down",4); wait(); moveEnemy("left",1)