For some reason my if statement is not even being executed at all. Cannot figure out what is wrong, I am trying to test a word called "fuor" and do some manipulations in the hash table I have.
if(table[getHashIndex(c.toString())].contains(c.toString()))
this is the line that is not executing
Tableclass
char[] c = word.toCharArray();
for(int i=0;i<word.length()-1;i++)
{
char tempChar= c[i];
c[i]=c[i+1];
c[i+1]=tempChar;
if(table[getHashIndex(c.toString())].contains(c.toString()))
{
list.add(c.toString());
System.out.println("GOT IT BABY");
}
c = word.toCharArray();
}
public int getHashIndex(String word){
int key = 7;
//Adding ASCII values of string
//To determine the index
for(int i = 0 ; i < word.length(); i++){
key = key*BASE+(int)word.charAt(i);
//Accounting for integer overflow
if(key<0)
{
key*=-1;
}
}
key %= sizeOfTable;
return key;
}
//Bucket class
public boolean contains(String word){
Node insert = start;
//Traversing the list to find a match
while(insert!=null){
if(word.equalsIgnoreCase(insert.item))
return true;
insert = insert.next;
}
//did not find a match
return false;
}