Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6566469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:13:15+00:00 2026-05-25T14:13:15+00:00

I am having a java ArrayList of integer ArrayList <Integer> ageList = new ArrayList

  • 0

I am having a java ArrayList of integer

ArrayList <Integer> ageList  = new ArrayList <Integer>();

I am having some integer values in this arrayList. I want to create a new ArrayList which has all elements in the above arrayList which passes a condition, like value between 25 and 35. ie if my ageList contains values

{12,234,45,33,28,56,27}

my newList should contain

{33,28,27}

How can I achieve this?

Note: I came to java from objective C background, where I used NSPredicate to easly do such kind of things..Any similiar methods in java?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:13:15+00:00Added an answer on May 25, 2026 at 2:13 pm

    There is no “filter” facility in the standard API. (There is in Guava and Apache Commons however.) You’ll have to create a new list, loop through the original list and manually add the elements in range 25-35 to the new list.

    If you have no intention to keep the original list, you could remove the elements out of range using an Iterator and the Iterator.remove method.

    If you have no duplicates in your list, you could use a TreeSet in which case you could get all elements in a specific range using headSet / tailSet.

    Related question: (possibly even a duplicate actually)

    • What is the best way to filter a Java Collection?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem using the java.text.MessageFormat object. I'm trying to create SQL insert
I'm having some trouble navigating Java's rule for inferring generic type parameters. Consider the
Check this, List<String> list = new ArrayList<String>(); for (int i = 0; i <
I am having one problem in java arraylist. I am good in databases :)
I'm having trouble getting the right number of elements in the ArrayList alt in
Im learning Java and having a problem with ArrayList. Firstly I have a class
I'm learning Java and I'm having a problem with ArrayList and Random . I
I'm having some problems with the stack in java... I'm implementing quicksort using an
I am having this problem in below code as my ArrayList both name and
In the following java class i'm having a method authenticate, in which i'm using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.