Hi,
Can anyone give me a clue what's wrong with the following code, it
compiles fine but errors on running with a NullPointerException:
for (int i = 0; i < adic.length; i++) {
int cntone = 0;
int cnttwo = 1;
for (cntone = 0; cntone < adic.length; cntone++) {
if (adic[i].word.equals(adic[cntone].word)) {
adic[i].links[cnttwo] = adic[cntone].links[0];
//delete adic[cntone]
cnttwo++;
}
}
}
Basically it's supposed to be searching an anagram dictionary. Psuedo
as
follows:
- take adic[i]
- if adic[i].word = adic[cntone].word, adic[i].links[cnttwo] = adic
[cntone].links[0]
- increment cnttwo
- loop
adic[i].links[0] contains the first word I already know matches the
anagram, in the below the first is adic.word, second adic.links[0]...
ehinorsstw worthiness
ghinnoorttw worthington
ehlorsstw worthless
eehlnorsssstw worthlessness
horstw worths
Thanks for any help,
Darryl