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

  • SEARCH
  • Home
  • 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 6326051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:00:35+00:00 2026-05-24T17:00:35+00:00

I am working with a java.util.List which is expected to contain approximately 70k Objects.

  • 0

I am working with a java.util.List which is expected to contain approximately 70k Objects. It is built up from an ordered database query, so it is always in the same order every time. This list is being iterated over as part of a long running task which can get halted due to external issues. So I need to skip X elements in the list the next time the task runs.

Handling this in the database query that builds the list is not an option for various reasons.

What is the most efficient way to skip over X items in a list before doing the heavy lifting?

int skip = getNumberOfItemsToSkip();
int count = 0;
for(MyThing thing : bigList){
 if(count >= skip){
  //do stuff
 }
}

OR

int skip = getNumberOfItemsToSkip();
int count = 0;
//does subList maintain the order????
List<MyThing> sublist = bigList.subList(skip, bigList.size() - 1);
for(MyThing thing : sublist){
  //do stuff
}

Is there another way?

  • 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-24T17:00:35+00:00Added an answer on May 24, 2026 at 5:00 pm

    In this case I would not use the an enhanced for loop. If you access by index, then you could simply start and end at a range that makes since.

    for(int i = getNumberOfItemsToSkip(); i < bigList.size(); i++) {
      Foo foo = bigList.get(i);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working through some tutorials and examples of java.util.concurrent package. Usually example authors put
I have been working in Java/J2ee projects, in which I follow the Maven structure.
I working on app what should get list of users from db and update
I've got a java.util.List bind to a JTable, if I want to refresh the
I'm currently working on a Doubly Linked List project in my college java course.
I am working at a contacl list database application and when i click on
My API allows library client to pass Date: method(java.util.Date date) Working with Joda-Time ,
I'm attempting to write a small library which will convert Java objects, through reflection,
I am working in Java, inserting data from HashMaps of certain types into a
While working with Java, I find it hard to position my main window in

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.