When you declare your lista
and listb
arrays, you use a
as the length, but at that time, it's 0
. You haven't assigned the user's value to a
yet.
Create your arrays after you have the length from the input.
a = input.nextInt();
double [] lista = new double [a]; //create array
double [] listb = new double [a]; //create array