aspose file tools*
The moose likes Java in General and the fly likes how to get filtered values from list<String> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to get filtered values from list<String>" Watch "how to get filtered values from list<String>" New topic
Author

how to get filtered values from list<String>

srikanth Thandra
Ranch Hand

Joined: Mar 04, 2009
Posts: 42

Hi guys,

I have a requirement of applying filter on list<String>. I am building a list<String> say cityNamesList, which contains values like below:

KOTHAPETA,PEDDAPALLE,KUPPAM,SIRCILLA,KAKINADA RURAL,PONNUR etc..
I am having a text box in the user interface side. When the user types a character in the text box, i capture that character and have to show the city names containing that character that user typed.

Ex: If user has typed K then from the above list i have to show the city names that contains letter 'K'

How to achieve this? Kindly give any ideas?


Thanx in advance,
Srikanth
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

so far what you have done? please post the detail, so that we can help you.
Steven Bruton
Greenhorn

Joined: Mar 07, 2011
Posts: 13
Add a document listener to the text field to capture the input and to filter the list you could create a method like so;



Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

The Google Guava collections libraries do this naturally. They have a "filter" function that iterates over a collection, which can be an List, ArrayList, Set, etc.
Free and open source.
 
 
subject: how to get filtered values from list<String>