Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

extract particular elements from arraylist

 
Raj Kumar Bindal
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to extract particular elements from an arraylist.
eg:
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
author
Marshal
Pie
Posts: 20881
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Henry
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic