I have seen many answers with respect to the above error in Java, however most of them are telling what the error is, and I cannot find a way to correct it.
This is a snippet of my code in Java:
public static void optimalAlignmentScoreBU(String r, String s, int matchScore, int transition, int transversion, int indel) {
int m = r.length();
int n = s.length();
Node[][] strg = new Node[m + 1][n + 1];
// base cases
strg[m][n].val = 0;
}
I get error at the line where I write strg[m][n].val =0; I have created a Node class as follows:
// ELEMENT OF DP MATRIX IS OF TYPE NODE
public class Node {
int val;
ArrayList<Pair<Integer>> arrows = new ArrayList<Pair<Integer>>();
}
// PAIR CLASS
public static class Pair<T> {
T p1;
T p2;
public Pair(T p1, T p2) {
this.p1 = p1;
this.p2 = p2;
}
}
Can you tell me what is going wrong? Why is NULL being pointed? What can I do to correct this?