you may have noticed not all of your code is showing, it stopped at some < sign, the rest was discarded as unexpected HTML code, because you did not enclode everything with PRE tags (that is what the code widget is for, or the "paste as code block" dialog).
The clue usually is in the error message you are getting "Index 0 out of bounds for length 0"; you do not really want a zero-length array, do you?
static int ver;
static int prev=new int[ver];
Now static code such as the initialization of prev gets executed at once when the class is referenced for the first time, and ver is still zero at that time. You'll have to reorganize things a bit...