- How do I find the filename of a file?
You can use the
File
method.getName()
- I’m confused about how to use an
ArrayList
as the value within aHashMap
. How do I create and update anArrayList
for each word?
Each word should map to a separate
ArrayList
. When you encounter a key that isn’t already in theHashMap
, you should create a newArrayList
and useHashMap.put()
to insert the key and its associatedArrayList
. When you want to add to theArrayList
of a key that is already in theHashMap
, you should useHashMap.get()
to get theArrayList
, update it, then useHashMap.put()
to put the key and the updatedArrayList
back into theHashMap
. - I’m not sure how to go about not reusing words in
GladLibs
. How do I make sure the new word hasn’t been used already? Where do I write this code?
Think about what type of a loop you will need – do you know how many times this loop will need to run? When will you want to stop the loop? To figure out where to add this code, think about where you generate new words and when you could check whether these have been used already.
- Why am I getting a
null pointer exception
whenever I try to call a method on myHashMap
?
Make sure you have initialized your
HashMap
before calling methods on it. Also, if you are declaring and initializing it in different places, make sure that you have not declared it a second time when you initialize it. - My
LogAnalyzer
class prints out all the values correctly except for the date/time. Does the time zone setting in the computer have an impact on the output value from the.getAccessTime()
method?
Yes, if your time zone is different from Durham, USA, you may want to temporarily change the time zone on your computer.
- Where can I find the dictionary files to use for my
VigenereBreaker
?
The dictionary files are included in the starter program you download. They are inside the folder called ‘dictionaries’.