Ask Experts Questions for FREE Help !
Ask
    spiky22's Avatar
    spiky22 Posts: 1, Reputation: 1
    New Member
     
    #1

    Mar 5, 2015, 07:34 PM
    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);}
    CravenMorhead's Avatar
    CravenMorhead Posts: 4,532, Reputation: 1065
    Adult Sexuality Expert
     
    #2

    Mar 6, 2015, 08:51 AM
    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?

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

MATH, I have 2 put this in descending powers... [ 8 Answers ]

I have 2 put this in descending powers... 7x-2+3xto the 5th power - 4x to the 2nd power +x to the 4th power is the answer.. 7x-2 +x to the 4th power 3xto the 5th power - 4x to the 2nd power +x to the 4th power +7x-2 is this correct?

MATH, I have 2 put this in descending powers... [ 3 Answers ]

I have 2 put this in descending powers... 7x-2+3xto the 5th power - 4x to the 2nd power +x to the 4th power is the answer.. 7x-2 +x to the 4th power 3xto the 5th power - 4x to the 2nd power +x to the 4th power +7x-2 is this correct?

A parachutist descending at a speed of 10.60 m/s loses a shoe at an altitude of 57.60 [ 13 Answers ]

A parachutist descending at a speed of 10.60 m/s loses a shoe at an altitude of 57.60 m. (a) When does the shoe reach the ground?

Create column with descending numbers corresponding to data in another column. [ 1 Answers ]

I created an alphabetized column with names. In another column I put an x next to those names that were heads of households leaving the rest blank. I would like to create a new column that would recognize the x then insert a number in the cell next to the x in descending order (i.e. 1-50).


View more questions Search