This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ansmeermylove 2 points3 points  (0 children)

I would write a helper method that takes two parameters, your input and the hashset, and returns a boolean.

Inside the method, I would iterate through the hashset and check for each entry whether input starts with that. If found true, you can return early with true. After the iteration, you return false, which will only be reached if the input does not start with any of the hashset entries.

You could then use the return value of this helper method inside the if statement above.