Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Arranging An Array In Java

Options
  • 14-03-2003 11:16am
    #1
    Registered Users Posts: 494 ✭✭


    Hi,

    Just a quick question that's probably easily answered. Ok, I've got a program and in it, a user enters in a series of numbers (results in this case) which are stored in an array. What I want to know is, how can i arrange this array in ascending order? I'm relatively new to Java, so please, be gentle.


Comments

  • Registered Users Posts: 1,931 ✭✭✭Zab


    Have a look at the class java.util.Arrays.

    Zab.


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    and do you own fecken homework :mad:


  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    Take a look at the article on comparing objects on http://www.onjava.com at the moment.
    very informative.


  • Registered Users Posts: 683 ✭✭✭TenLeftFingers


    Good link Enygma, there's stuff there I can use on my project :)


  • Closed Accounts Posts: 741 ✭✭✭michaelanthony


    Do a *******ort


  • Advertisement
  • Closed Accounts Posts: 741 ✭✭✭michaelanthony


    Do a Bubble sort


  • Registered Users Posts: 2,281 ✭✭✭DeadBankClerk


    [php]
    float result_array [];

    // enter values into array

    float temp;
    for (int i = 0; i < result_array.length - 1; i++)
    for (int j = i + 1; j < result_array.length; j++)
    if (result_array[j] > result_array)
    {
    temp = result_array;
    result_array = result_array[j];
    result_Array[j] = temp;
    }
    [/php]


  • Registered Users Posts: 19,396 ✭✭✭✭Karoma


    look up sorts (bubble,quick,etc.) on java.sun.com & see demo's in C:\j2sdkfolder\demo\applets


Advertisement