wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets 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

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:

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,
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

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

Joined: Aug 11, 2007
Posts: 4646

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.
I agree. Here's the link: http://aspose.com/file-tools
subject: how to get filtered values from list<String>
Similar Threads
Capturing a list of details from the UI to ActionForm
How to bind list values from jsp page in spring.
Drop Down Box in Struts - Select Default Value Implementation
multiple Checkbox
Listing and Action Form Validation