Question: Write a program that asks user for their input of number of elements to be sorted and then uses bubbleSort to sort them. An ArrayList

Write a program that asks user for their input of number of elements to be sorted and then uses bubbleSort to sort them. An ArrayList must be used to solve this question. Must use the template given below.
//Use Appropriate imports here.
public class bubbleSortArrayList {
public static void main(String[] args) {
ArrayList items = new ArrayList<>(); Scanner inp = new Scanner(System.in);
//Ask the user for how many elements to be added.
System.out.println("Enter the number of elements to be added");
int HowManyElements = inp.nextInt();
//Complete the for loop for adding the elements to the ArrayList.
for (int i = 1 ; i <=; i++){
}
//Print out the Original ArrayList after user input Here.
/* Call the non-static bubbleSort method using the instantiated object list of the class it is defined
list.bubbleSort(items);
}
/*Complete the BubbleSort Algorithm as per the ArrayList usage and methods. Remember, the way to access the index elements is different in arrayLists than in Arrays.
public void bubbleSort (){ for (){
} }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!