Vertex [] vertices = new Vertex[n];
int [] numbers = new int[n*2];
AdjacencyList[] all = new AdjacencyList [n+1];
for (Vertex v : vertices)
{
System.out.println(v.value);
AdjacencyList a = new AdjacencyList(v);
for (int i = 0; i < n; i += 2)
{
if (numbers[i] == v.value){
a.connected[i] = vertices[i+1];//array index out of bounds exception:19
else { a.connected[i] = v; }
}
all[0] = a; //add the finished adjacency list to the array
}
with n = 19 can I'm getting an index out of bounds error at the point indicated in the code. I'm not sure where I'm going wrong, as everything is still within the bounds of 19
vertices = list of Vertex [1-19], numbers is a flattened array of edges