I am trying to implement 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];
for(i=0;i<=max/5;i++)
{
bucket[i]=new ArrayList<Integer>();
}
But the above code doesn't work and throws an error. It states "generic array creation".I know that generic array types are not allowed in java but I can't understand where generic types comes here I mean something like or .I also want to know is there a way to cast Integer to int while creating the ArrayList I hope doing so will fix this.
ArrayList<Integer>[5]
justArrayList<Integer>()
– Jorge Campos 2 days agoArrayList<Integer>[]
– hoosssein 2 days ago