I'm just learning java and this is my first sort program. I can't get it to run. I sure could use some help.

public class SortCharArray
{
    public static void main(String[] args) throws Exception
    {
        char[] someChars = new char[10];
        int x;



        for(x = 0; x < someChars.length; ++x)
        {
            System.out.print("Enter a character ");
            someChars[x] = (char)System.in.read();
            System.in.read(); System.in.read();

        }

        System.out.println("Before sort");
        for(x = 0; x < someChars.length; ++x)
         System.out.print(someChars[x] + " ");

        bubbleSort(someChars, someChars.length);

        System.out.println("\nAfter sort");
        for(x = 0; x < someChars.length; ++x)
         System.out.print(someChars[x] + " ");
         System.out.println();    

    }     

        public static void bubbleSort(char[] array, int len)
    {
        int a, b;
        char temp;
        int highSubscript = len - 1;
        for(a = 0; a < highSubscript; ++a)
           {
            for(b = 0; b < highSubscript; ++b)
              if(array[b] > array[b = 1])
              {
                  temp = array[b];
                  array[b] = array[b + 1];
                  array[b + 1] = temp;
              }
            }
    }        

}

Edited 3 Years Ago by happygeek: fixed formatting

Please use code tags when posting code. Read the information in the links below.

This is how I code it in c/c++:

for(a = 0; a < highSubscript-1; ++a)
{
    for(b = 0; b < highSubscript; ++b)
    {
            if(array[a] > array[b])
            {
                temp = array[a];
                array[a] = array[b];
                array[b] = temp;
             }
      }
}

I think you may be best off using KeyboardReader to take input.
And you definitely have to use Ancient Dragon's suggestion for the bubble sort.

This question has already been answered. Start a new discussion instead.