This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Bouncing a String Against a List of Strings  RSS feed

 
Ranch Hand
Posts: 1869
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: 1879
50
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: 1869
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'.
 
Rancher
Posts: 2842
96
  • 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...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!