How to create ArrayList in each index of an array in Java? -


I am trying to apply the bucket sort and I want to create an arraylist for each index of an array. I want to do something like this:

  int bucket [] = new int [max + 1]; (Baltic [i] = New Arreelist & lt; integer & gt; ();}  

For I & lt; i = 0; i & lt; = max / 5; i ++) But the above code does not work and throws an error, it says "generic array building." I know that generic array types are not allowed in Java but I do not understand where the normal types are I mean Something like this or I also want to know that one way to complete the integer is ArrayList. While doing this, I hope that by doing this, it will be alright.

Your data type Do not match ...

You enter ArrayList & lt; Integer & gt; in an int [] .

Please do not have to do this type of data!

Please do you have to reconsider:

  int [] [] ArrayList & lt; int [] & ArrayList & gt; ArrayList & lt; Integer & gt; & gt;  

If you want high performance, you should keep an eye on GNU Trove, and

  ArrayList & lt; TIntList & gt;   

to the array list & lt; ArrayList & lt; Integer & gt; & Gt; should use less memory than.

If your data size is correct, then probably

  int [] [] bucket = new int [max + 1] [max / 5 + 1] of Are looking for;  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -