I’m trying to teach myself java. I’m trying to write a program that takes a string with no spaces and separates it into words.
My plan of attack was to partition the dictionary based on word length, then walk through the string finding possible variations.
I ran into a problem with making my dictionary. I’ve read up on the various collections, and I thought that an array (of length 20 or so) holding HashSets would work best for me, but I can’t figure out how to declare it. I think an array would be good because the index would represent the length, then a HashSet would be good because I could store the words as keys for fast look ups.
This is something that I could do in seconds in the scripting languages I’m most comfortable with, but I’ve spent about 5 hours reading up and trying to figure it out in Java. Historically speaking, this is evidence that I’m doing something fundamentally wrong. Can someone with more java acumen help get me going?
If your only question is the syntax, then to create an array of 20 HashSets, the syntax would be: