I am supposed to create an arraylist from an integer[] array, iterating the elements in the list in decending order
ex:
int[] array = {1,4,2,3,5};
goes into array list to become {5,4,3,2,1}
how do i even being to do this (without first sorting the array and then putting it into the list?)
i am trying take an index from the array, check to see if it is smaller than the current number in the array, and bump it down into the ArrayList, but so far no good. any help would be appriciated
int[] intArray = {1,9,4,5,3,2,8};
ArrayList<Integer> list = new ArrayList(1);
for(int i = 0; i < intArray.length; i++ )
{
if(i == 0){
list.add(intArray[i]);
}
//if i is not zero and intArray value at i is less than value at previous index
int[] intArray = {1,9,4,5,3,2,8};
//used to see what list looks like
ListIterator itr = list.listIterator();
while(itr.hasNext())
System.out.println(itr.next());