Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems searching through a list

 
rosin tuck
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic