• Do two hacks of the 4
  • Sort an ArrayList in descending order and swap the first and last elements (Completed)
  • Find and display the hashCode of an Arraylist before and after being sorted (Completed)
  • Return "ascending" if the list is sorted in ascending order, return "descending" if it is descending, and return "neither" if neither
  • Replace 3 elements in an ArrayList with another ArrayList and reverse the order of the new list
ArrayList<Integer> numbers = new ArrayList<Integer>();
numbers.add(1);
numbers.add(4);
numbers.add(2);
numbers.add(3);
true

Sort an ArrayList in descending order and swap the first and last elements and

Find and display the hashCode of an Arraylist before and after being sorted

System.out.println("Before Sorting: "+ numbers + ", the hashcode is " + numbers.hashCode());
Collections.sort(numbers, Collections.reverseOrder());
System.out.println("After Sorting: "+ numbers + ", the hashcode is " + numbers.hashCode());
Collections.swap(numbers, 0, numbers.size()-1);
System.out.println("After Sorting and Swapping first and last numbers: "+ numbers + ", the hashcode is " + numbers.hashCode());
Before Sorting: [1, 4, 2, 3], the hashcode is 957221
After Sorting: [4, 3, 2, 1], the hashcode is 1045631
After Sorting and Swapping first and last numbers: [1, 3, 2, 4], the hashcode is 956261