Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Other Programming (https://www.askmehelpdesk.com/forumdisplay.php?f=437)
-   -   Descending order (https://www.askmehelpdesk.com/showthread.php?t=809031)

  • Mar 5, 2015, 07:34 PM
    spiky22
    Descending order
    I can only get correct nswer for two digit but when I mix 3 digit with two digit I cannot get correct output.
    For output I need to display in descending order. Plese an anybody healp? In java

    Code:

    my code is:String acc = JOptionPane.showInputDialog("Enter a string:");
                    String[] s = acc.split(",");
                    ArrayList<String> arraylist = new ArrayList<String>();
                    for (int i = 0; i < s.length; i++) {
                            arraylist.add(s[i]);
                           
                    }System.out.println(arraylist);
           
                                                                         
                      Collections.sort(arraylist, Collections.reverseOrder());
                            System.out.println("ArrayList in descending order:");
                          for(String str: arraylist){
                                      System.out.println(str);}

  • Mar 6, 2015, 08:51 AM
    CravenMorhead
    If these are numbers why don't you convert them to Integers or Floats? Then the sort functions should have an easier time with it.

    What does the output look like when you put in 3 digit numbers?

  • All times are GMT -7. The time now is 05:08 PM.