Only a little comment :-)

When I have to make many string comparisons just like in this code fragment, I prefer 
using the intern() method of the String class.

The code changes to:

String s = request.getParameter("collection");
s = s.intern();

// Now comparisons can be made through ==

if (s == "scopus") {
...
}
else if (s == "securetrak") {
...
}
else ...

String comparisons are expensive. If the number of comparisons is large enough, the 
cost of the intern() call becomes insignificant.
Of course, I am speaking about more than two comparisons. Anybody have made some 
tests? I have never had time enough. I use this when I have to do more that ten 
comparisons, but I suppose it can provide benefits with less comparisons.

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to