What does the “- 97” mean in the following code?
if (dictionary[(int) word.charAt(0) -97 ].contains(word))
we created an array of 26 LinkedList to simulate a dictionary. each list contains all words starting with “a”, “b”, “c”, …. “z”. the code was given by instructor.
Here is the attached note:
To search a word in a specific MyLinkedList
Assume that the word you want to search is in a String type variable called wordstr.
dictionary [(int)wordstr.charAt(0) - 97].contains(wordstr) ;
would allow you to jump to the correct linked list, and the contains will return true/false depending if the word is in the list or not.
I just don’t understand why the “-97”