This week's giveaway is in the Beginning Java forum.
We're giving away four copies of Bad Programming Practices 101 (e-book) and have Karl Beecher on-line!
See this thread for details.
Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Bouncing a String Against a List of Strings  RSS feed

 
Ranch Hand
Posts: 1840
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I would like to check a string for specific contents using a list of strings in lieu of long hand coding for each possibility.

That way I could set up an application parameter so that I could control the list on the fly.

My current code is:

 
Bartender
Posts: 1814
46
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming that itemChild.getItdsc() returns a list, why cant you just check each item against another list ?

 
Steve Dyke
Ranch Hand
Posts: 1840
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

salvin francis wrote:Assuming that itemChild.getItdsc() returns a list, why cant you just check each item against another list ?



Sorry,  itemChild.getItdsc() is a simple string(drawing title) like: 'SEAT ASSY, ISB, 5100 T/C'.
 
Master Rancher
Posts: 2696
92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Steve,

this one turned out to be more difficult than I thought. I took Salvins code, and I changed it a little to take into account that your itdsc contains elements with more than one String. I give two ways, biggest problem that took me some time was to realize that if a and b are two Sets, then a,addAll(b) does not return a, but a boolean, leading to one of those dreaded incomprehensible compiler errors...
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!