Results 1 to 2 of 2

Thread: Sorting

  1. #1
    amzers is offline Member
    Join Date
    Dec 2010
    Posts
    31
    Rep Power
    0

    Default Sorting

    hey guys,i copied a code on my lecturer on the board and i know this seems odd but it doesnt work,non of us figured it out

    Java Code:
    public class bubblesort {
        static void display(int[]array){
            for (int i=0; i<array.length; ++i);
            System.out.println(array[i] + " ");
            System.out.println("\n");
        }
        public static void main(String[]args){
            int[]arr={50,30,20,10,40};
            System.out.println("INITIAL ARRAY");
            display(arr);
            BubbleSorting.bubbleSort(arr);
        }
    }
    
    
    public class bubblesorting {
        public static void bubbleSort(int[]array){
            int temp;
            for(int pass=1; pass<array.length; ++pass){
                for (int i=0; i<array.length-1; ++i){
                    if(array[i]>array[i+i]){
                        temp=array[i];
                        array[i]=array[i+i];
                        array[i+i]=temp;
                    }
                    
                    }
                System.out.println("Pass" + pass + ":");
                BubbleSorting.display(array);
                }
            }
        }
    that is two different coding,from the other classes they said there has something to be swapped there

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

Similar Threads

  1. C# Sorting
    By larry_d1990 in forum New To Java
    Replies: 8
    Last Post: 01-27-2011, 09:51 AM
  2. Sorting
    By Freakzoyd in forum New To Java
    Replies: 3
    Last Post: 01-21-2011, 02:02 AM
  3. little help with sorting
    By drgnfire25 in forum New To Java
    Replies: 3
    Last Post: 01-15-2011, 09:23 PM
  4. Help in sorting
    By nn12 in forum New To Java
    Replies: 3
    Last Post: 01-08-2011, 06:15 PM
  5. sorting
    By jot321 in forum New To Java
    Replies: 18
    Last Post: 10-02-2008, 10:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •