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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:49:12+00:00 2026-06-15T14:49:12+00:00

ArrayList(int initialCapacity) and other collections in java work on int index. Can’t there be

  • 0
ArrayList(int initialCapacity)

and other collections in java work on int index.

Can’t there be cases where int is not enough and there might be need for more than range of int?

UPDATE:
Java 10 or some other version would have to develop new Collection framework for this. As using long with present Collections would break the backward compatibility. Isn’t it?

  • 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-06-15T14:49:13+00:00Added an answer on June 15, 2026 at 2:49 pm

    There can be in theory, but at present such large arrays (arrays with indexes outside the range of an integer) aren’t supported by the JVM, and thus ArrayList doesn’t support this either.

    Is there a need for it? This isn’t part of the question per-se, but seems to come up a lot so I’ll address it anyway. The short answer is in most situations, no, but in certain ones, yes. The upper value of an int in Java is 2,147,483,647, a tad over 2 billion. If this were an array of bytes we were talking about, that puts the upper limit at slightly over 2GB in terms of the amount of bytes we can store in an array. Back when Java was conceived and it wasn’t unusal for a typical machine to have a thousand times less memory than that, it clearly wasn’t too much of an issue – but now even a low end (desktop/laptop) machine has more memory than that, let alone a big server, so clearly it’s no longer a limitation that no-one can ever reach. (Yes, we could pack the bytes into a wrapper object and make an array of those, but that’s not the point we’re addressing here.) If we switch to the long data type, then that pushes the upper limit of a byte array to well over 9.2 Exabytes (over 9 billion GB.) That puts us firmly back into “we don’t need to sensibly worry about that limit” territory for at least the foreseeable future.

    So, is Java making this change? One of the plans for Java 10 is due to tackle “big data” which may well include support for arrays with long based indexes. Obviously this is a long way off, but Oracle is at least thinking about it:

    On the table for JDK 9 is a move to make the Java Virtual Machine (JVM) hypervisor-aware as well as to improve its performance, while JDK 10 could move from 32-bit to 64-bit addressable arrays for larger data sets.

    You could theoretically work around this limitation by using your own collection classes which used multiple arrays to store their data, thus bypassing the implicit limit of an int – so it is somewhat possible if you really need this functionality now, just rather messy at present.

    In terms of backwards compatibility if this feature comes in? Well you obviously couldn’t just change all the ints to longs, there would need to be some more boilerplate there and, depending on implementation choices, perhaps even new collection types for these large collections (considering I doubt they’d find their way into most Java code, this may well be the best option.) Regardless, the point is that while backwards compatibility is of course a concern, there are a number of potential ways around this so it’s not a show stopper by any stretch of the imagination.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ArrayList.remove(int index) is working with the anonymous instance of ActionListener class :- DeleteModule.java :-
I have the following code: List<int> intList = new ArrayList<int>(); for (int index =
Possible Duplicate: How to convert List<Integer> to int[] in Java? I have an ArrayList
How can i soth below arraylist according to int value. But if you compiled
How do you find the index of an int stored inside an ArrayList? public
//arrayList.h template<class T> class arrayList{ public: // constructor, copy constructor and destructor arrayList(int initialCapacity
I was wondering what the performance impact would be when using ArrayList.ListIterator(int index -
What's meant by parameter (int initialCapacity) in an ArrayList , I thought it's the
What is the most elegant way to implement this function: ArrayList generatePrimes(int n) This
I'm trying to delete an int[] from an ArrayList. Due to my code I

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.