Start New Discussion within our Software Development Community

WHAT IS WRONG HERE?WHY WON'T THIS SORT?

public class bubble
{

    public static void main (String[] args)
    {
        boolean Finished;
        int[] intRand = new int[11];
        int[] unSorted = new int[11];
        int intStore;
        int i;
        Finished = false;
        i = 1;
        while (i < 11)
        {
            intRand[i] = (int)(java.lang.Math.random() * 100);
            unSorted[i] = intRand[i];
            i = i + 1;
        }

                do
        {
            Finished = true;
            for (i = 2; i < 11; ++i)
            {
                if (intRand[i] < intRand[i-1])
                {
                    intStore = intRand[i];
                    intRand[i] = intRand[i-1];
                    intRand[i-1] = intStore;
                    Finished = false;
                }
            }

        }
            while (Finished==true );

                System.out.println("Unsorted        Sorted");
        i = 1;
        while (i < 11)
        {
            System.out.print(unSorted[i] + "\t"+ "\t");
            System.ouWHATt.println(intRand[i]);
            i = i + 1;
        }
    }
}
package untitled4;

import java.util.*;

public class bubble
{

public static void main (String[] args)
{

int[] intRand = new int[11];
int[] unSorted = new int[11];


int i;
i = 1;
while (i < 11)
{
intRand[i] = (int)(java.lang.Math.random() * 100);
unSorted[i] = intRand[i];
i = i + 1;
}
Arrays.sort(intRand);
System.out.println("Hello");
for(i = 0; i<intRand.length;)
{
  System.out.print(unSorted[i] + "\t"+ "\t");
  System.out.println(intRand[i]);
  i++;
}
}
}

A lot more simpler dontcha think? Kinda ditched most of your code though.

This article has been dead for over six months. Start a new discussion instead.