File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes extract particular elements from arraylist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "extract particular elements from arraylist" Watch "extract particular elements from arraylist" New topic

extract particular elements from arraylist

Raj Kumar Bindal
Ranch Hand

Joined: Apr 15, 2006
Posts: 418
I want to extract particular elements from an arraylist.
If arraylist contains elements : Rajkumar , Shashii , Hari Kumar , paters , nam kumar

I want to take elements ending with kumar i.e. Rajkumar, Hari Kumar , nam kumar
How can i do it through efficient coding
Thanx in advance
Henry Wong

Joined: Sep 28, 2004
Posts: 20535

Well, lists are not sorted -- so I don't think there is anything more efficient than to just use an iterator, and checking each string member with its endsWith() method.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
I agree. Here's the link:
subject: extract particular elements from arraylist
It's not a secret anymore!