>

Friday, February 22, 2013

Sort Letters in a String Object

public void doSorting(String str)
    {
     char array[]=str.toCharArray();
     char temp;
     System.out.print("Given name :");
     for(int i=0;i<array.length;i++)
     {
         System.out.print(array[i]);
     }
     System.out.println();
     for(int i=0;i<array.length;i++)
     {
         for(int j=0;j<i;j++)
         {
             if(array[i]<array[j])
             {
                temp=array[j];
                array[j]=array[i];
                array[i]=temp;
             }
         }
   
     }

CONTENT WARNING:This is my own program.. It is for Educational purposes only. Please do not republish or reproduce with another name in online.
   

No comments:

Post a Comment

Please post your comments. Your comments make us to write more programs for you.