The assignment is to write a program that will read a set of numbers, sort the numbers, and print the array values. My issue is that everything works just fine until it comes to printing the array values.
package program11; import javax.swing.JOptionPane; public class Program11 { public static void main(String[] args) { double [] list = new double [10]; getList(list); sort(list); printList(list); } public static void getList(double [] theList){ for (int n = 0; n < theList.length; n++){ theList [n] = Double.parseDouble(JOptionPane.showInputDialog(null, "Enter a number:")); } } public static void sort(double [] theList){ double hold; for (int a = 0; a < theList.length - 1; a++){ for (int z = a + 1; z < theList.length; z++){ if (theList [a] > theList [z]){ hold = theList [a]; theList [a] = theList [z]; theList [z] = hold; } } } } public static void printList(double [] list){ JOptionPane.showMessageDialog(null, "The numbers are: " + (list)); } }
I know there's a problem with the printList method, but I'm not sure what exactly I need to do to get the program to display the array.