java - IndexOutOfBoundsException when removing ArrayList element -


i have code right here (using lwjgl should moot) try , pause game when pressing esc key. use arraylist keys keep track of pressed , isn't.

public list<integer> keys = new arraylist<integer>();  public void get() {     if (iskeydown(key_escape) && !keys.contains(key_escape)) {         keys.add(key_escape);         keyescape();     } }  public void rem() {     if (!iskeydown(key_escape) && keys.contains(key_escape))         keys.remove(key_escape); }  private void keyescape() {     screen.paused ^= true; } 

this called loop, get() , rem() 1 right after in loop, in order. gives me awesome java.lang.indexoutofboundsexception: index: 1, size: 1 @ keys.remove(key_escape); when let go of esc.

anyone have insight share?

what value of key_escape?

it might int value 1 instead of removing object value, remove object @ position 1 apparently not exist.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -