Hi,
I am a total newbie in java , and i am facing this issue. after allocating memory for my class instance, i am not able to access the variable in this instance.
here is the code for this.
Main function:
CreateGraph:String ip=args[0]; FileReader input = new FileReader(ip); BufferedReader bufRead = new BufferedReader(input); String line; int count = 0; line = bufRead.readLine(); // read first line int v = Integer.parseInt(line); //System.out.print("Value of number is "+ v); count++; g1=g1.createGraph(v,g1);
The output i am getting is :Graph createGraph(int v,Graph g1){ g1.numv=v; g1.g=new Vertex[v]; // g1.g[0].id=4; System.out.println("value of g[0].id is"+g1.g[0].id ); for (int i=0;i<v;i++) { g1.g[i]=new Vertex(); g1.g[i].id=i; } return g1;
Exception in thread "main" java.lang.NullPointerException
at graphcolouring.Graph.createGraph(Graph.java:21)
at graphcolouring.GraphColouring.main(GraphColouring. java:29)