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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Arranging An Array In Java

  • 14-03-2003 10:16am
    #1
    Registered Users, Registered Users 2 Posts: 509 ✭✭✭


    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, Registered Users 2 Posts: 1,931 ✭✭✭Zab


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

    Zab.


  • Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 Posts: 19,396 ✭✭✭✭Karoma


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


Advertisement