This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes Problems searching through a list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Problems searching through a list" Watch "Problems searching through a list" New topic
Author

Problems searching through a list

rosin tuck
Greenhorn

Joined: Jan 26, 2006
Posts: 5
Hey i have written a method to take two lists of strings as input, merge these two lists together, then go through each list individually and if it contains a word in the merge list, to return 1 otherwise return 0. However currently this only checks if the "exact" same string is in the list, as in it is case sensitive, i need it to be case insensitive for what i am trying to do


The return statement here is redundant i am just returning an int to test the method. Does anybody know how i can perform the same test while ignoring case? I would appreciate any help
Thanks
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I think you said the problem is that you want to ignore case so "hello" matches "Hello" in your search?

You could put everything into the list in lower case and do contains(word.toLowerCase())

You could make your own class instead of Strings ... something that holds a String and has an equals() method that ignores case.

Either of those sound useful?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
Consider Paul's rocket mass heater.
 
subject: Problems searching through a list
 
Similar Threads
Simple ArrayList conundrum?
Ternary Operator behavior in JAVA
read an expression and solve it...
How to sort a list of lists
Collection