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 813073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:18:05+00:00 2026-05-15T01:18:05+00:00

How can I split an ArrayList (size=1000) in multiple ArrayLists of the same size

  • 0

How can I split an ArrayList (size=1000) in multiple ArrayLists of the same size (=10) ?

ArrayList<Integer> results;
  • 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-15T01:18:05+00:00Added an answer on May 15, 2026 at 1:18 am

    You can use subList(int fromIndex, int toIndex) to get a view of a portion of the original list.

    From the API:

    Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the returned list is empty.) The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. The returned list supports all of the optional list operations supported by this list.

    Example:

    List<Integer> numbers = new ArrayList<Integer>(
        Arrays.asList(5,3,1,2,9,5,0,7)
    );
    
    List<Integer> head = numbers.subList(0, 4);
    List<Integer> tail = numbers.subList(4, 8);
    System.out.println(head); // prints "[5, 3, 1, 2]"
    System.out.println(tail); // prints "[9, 5, 0, 7]"
    
    Collections.sort(head);
    System.out.println(numbers); // prints "[1, 2, 3, 5, 9, 5, 0, 7]"
    
    tail.add(-1);
    System.out.println(numbers); // prints "[1, 2, 3, 5, 9, 5, 0, 7, -1]"
    

    If you need these chopped lists to be NOT a view, then simply create a new List from the subList. Here’s an example of putting a few of these things together:

    // chops a list into non-view sublists of length L
    static <T> List<List<T>> chopped(List<T> list, final int L) {
        List<List<T>> parts = new ArrayList<List<T>>();
        final int N = list.size();
        for (int i = 0; i < N; i += L) {
            parts.add(new ArrayList<T>(
                list.subList(i, Math.min(N, i + L)))
            );
        }
        return parts;
    }
    
    
    List<Integer> numbers = Collections.unmodifiableList(
        Arrays.asList(5,3,1,2,9,5,0,7)
    );
    List<List<Integer>> parts = chopped(numbers, 3);
    System.out.println(parts); // prints "[[5, 3, 1], [2, 9, 5], [0, 7]]"
    parts.get(0).add(-1);
    System.out.println(parts); // prints "[[5, 3, 1, -1], [2, 9, 5], [0, 7]]"
    System.out.println(numbers); // prints "[5, 3, 1, 2, 9, 5, 0, 7]" (unmodified!)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 426k
  • Answers 426k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Good unit test practice is to avoid state accumulated across… May 15, 2026 at 12:46 pm
  • Editorial Team
    Editorial Team added an answer The line: EditText totalbox = (EditText) findViewById(R.id.totalbox); Is not in… May 15, 2026 at 12:46 pm
  • Editorial Team
    Editorial Team added an answer I found a workaround. Using the .plist key "Application is… May 15, 2026 at 12:46 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.