This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
If the lists are constants, I use the Google Guava ImmutableList classes, which have very nice initialization code. I don't care how long it takes the compiler to generate the code, its never executed more than once.
My question is which one is better for performance. I have 101 "bad words" that I am filtering for a chat client. I want to know which is better for performance. The above were just examples of the "setting up" for the words.
John Price aka cc11rocks
john price wrote:My question is which one is better for performance.
There is nothing to have performance with in your sample code.
As others have written in other posts of yours, if you care about performance, you won't use either. You would use a Set. I would use one of the ImmutableSet classes from Guava. Probably a tree set, if you only have a few hundred entries.