I'm getting this weird exception report from other users:
java.lang.NullPointerException: Attempt to write to null array
at yuku.alkitab.base.util.Levenshtein.distance(Levenshtein.java:16)
The relevant snippet is:
private static final int deletion = 500;
public static int distance(String s, String t) {
// d is a table with m+1 rows and n+1 columns
int m = s.length();
int n = t.length();
int[][] d = new int[m + 1][n + 1];
for (int i = 0; i <= m; i++) {
d[i][0] = i * deletion; // <------ this is line 16
}
// more lines omitted
}
Examining the above code I could not find out how that exception can ever happened. Did I miss something?
All crash reports came from Android 6.0, API 23.
Please provide more information to the question. Currently the only thing that should make the code not work, is that it is not returning the value it should return (int).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.