Question: Write the following method that sorts an ArrayList of numbers: public static void sort(ArrayList list) Write a test program that prompts the user to enter

Write the following method that sorts an ArrayList of numbers:

public static void sort(ArrayList list)

Write a test program that prompts the user to enter five numbers, stores them in an array list, and displays them in increasing order.

This is the code I have so far and I am stuck:

import java.util.Scanner; import java.util.ArrayList; public class ArrayLists {

/** * @param args the command line arguments */ public static void main(String[] args) { Scanner scanner = new Scanner(System.in); } public static void sort(ArrayList list) { Scanner scanner = new Scanner(System.in); ArrayList numbers = new ArrayList(); System.out.println(" Please enter the numbers: "); while (scanner.hasNextInt()) { list.add(scanner.nextInt()); } } } }

What other code should I be putting into this. Thank you.

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!