Well, here i m trying store the some vertices(4) in an array. and trying to read them. But i m getting an error of "Array Index out of Bounds Exception.
I know the error is in the line i have highlighted(red). And i have tried various methods. But not working.
public void readInput()
Scanner input = null;
input = new Scanner(new FileInputStream("Test1.txt"));
int vertex = input.nextInt();
System.out.println("printing # of vertex "+vertex);
String array = new String[vertex];
System.out.println("array size "+ array.length);
// reading vertex from file and storing them in the array
the error that i get is
returned from absgraph
printing # of vertex 4
array size 4
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
----jGRASP wedge2: exit code for process is 1.
what fuction should i use?