Question: I can't fix this exception, please help me edit my code, the small file is a bunch of string. import java.util.Scanner; import java.util.Vector; import java.util.Arrays;
I can't fix this exception, please help me edit my code, the small file is a bunch of string.

import java.util.Scanner; import java.util.Vector; import java.util.Arrays; import java.io.File; import java.lang.Math;
public class HashTable{
//The size of the hash table. int TableSize; //The current number of elements in the hash table. int NumElements; //The variable T represents the array used for the table. // DECLARE YOUR TABLE DATA STRUCTURE HERE String[] T; public HashTable(){ NumElements = 0; TableSize = 997; T=new String[TableSize]; // INITIALZE YOUR TABLE DATA STRUCTURE HERE } /* hash(s) = ((3^0)*s[0] + (3^1)*s[1] + (3^2)*s[2] + ... + (3^(k-1))*s[k-1]) mod TableSize (where s is a string, k is the length of s and s[i] is the i^th character of s) Return the hash code for the provided string. The returned value is in the range [0,TableSize-1].
NOTE: do NOT use Java's built in pow function to compute powers of 3. To avoid integer overflows, write a method that iteratively computes powers and uses modular arithmetic at each step. */ public int hash(String s){ int h = 0; for(int i=0; i=0.75){ TableSize=TableSize*2; resize(TableSize); } int i = hash(s); int j = 0; int k = i; while(T[k]!= null){ j++; k=(i+(j*j))%TableSize; } T[k]=s; return k; } /* find(s) Search for the string s in the hash table. If s is found, return the index at which it was found. If s is not found, return -1. */ public int find(String s){ int i = hash(s); int j = 0; int k = i; while (true){ String element = T[k]; if (element == null) return -1; if (s.equals(element)) return k; j++; k=(i+(j*j))%TableSize; } } /* remove(s) Remove the value s from the hash table if it is present. If s was removed, return the index at which it was removed from. If s was not removed, return -1. */ public int remove(String s){ /*NumElements--; if((double)NumElements/TableSize } /* resize() Resize the hash table to be a prime within the load factor requirements. */ public void resize(int newSize){ while(!isPrime(newSize)){ newSize++; } String[] T2= new String[newSize]; T=T2; } public boolean isPrime(int num){ if(num==2){ return true; } if(num>2){ for(int i=2;i 0){ try{ s = new Scanner(new File(args[0])); } catch(java.io.FileNotFoundException e){ System.out.printf("Unable to open %s ",args[0]); return; } System.out.printf("Reading input values from %s. ",args[0]); }else{ interactiveMode = true; s = new Scanner(System.in); } s.useDelimiter(" "); if (interactiveMode){ System.out.printf("Enter a list of strings to store in the hash table, one per line. "); System.out.printf("To end the list, enter '###'. "); }else{ System.out.printf("Reading table values from %s. ",args[0]); } Vector tableValues = new Vector(); Vector searchValues = new Vector(); Vector removeValues = new Vector(); String nextWord; while(s.hasNext() && !(nextWord = s.next().trim()).equals("###")) tableValues.add(nextWord); System.out.printf("Read %d strings. ",tableValues.size()); if (interactiveMode){ System.out.printf("Enter a list of strings to search for in the hash table, one per line. "); System.out.printf("To end the list, enter '###'. "); }else{ System.out.printf("Reading search values from %s. ",args[0]); } while(s.hasNext() && !(nextWord = s.next().trim()).equals("###")) searchValues.add(nextWord); System.out.printf("Read %d strings. ",searchValues.size()); if (interactiveMode){ System.out.printf("Enter a list of strings to remove from the hash table, one per line. "); System.out.printf("To end the list, enter '###'. "); }else{ System.out.printf("Reading remove values from %s. ",args[0]); } while(s.hasNext() && !(nextWord = s.next().trim()).equals("###")) removeValues.add(nextWord); System.out.printf("Read %d strings. ",removeValues.size()); HashTable H = new HashTable(); long startTime, endTime; double totalTimeSeconds; startTime = System.currentTimeMillis();
for(int i = 0; i
for(int i = 0; i
for(int i = 0; i Reading input values from small-txt. Reading table values from small-txt Read 22107 strings. Reading search values from small-txt. Read 1865 strings ding remove values from small-txt. ead strings xception in thread "main" java. lang Array Indexout Bounds Exception 387 at HashTable insert HashTable java:72 at HashTable main HashTable java :229