Write a java program to sort the give string

Here we explain how to write a program to sort the give string. Suppose  that there is array of string is StringArray which contain the value as java, fore, cast, for, you. The java class StringSortingTest.java is use to sort the give string. So see the code for this class as 


StringSortingTest.java

package com.javaforecast4u;

public class StringSortingTest {
    public static void main(String args[])
    {
        
         String StringArray[]={"java","fore","cast","for","you"};
        int n=StringArray.length;
       String temp;
      for(int i=0;i<n;i++)
         {
            for(int j=i+1;j<n;j++)
             {
                if(StringArray[i].compareTo(StringArray[j])>0)
                 {
                 temp=StringArray[i];
                 StringArray[i]=StringArray[j];
                 StringArray[j]=temp;
                 }
             }
         }
         for(int i=0;i<n;i++)
         {
             System.out.println(StringArray[i]);
         }
    }

}

 Output:


cast
for
fore
java
you

69 comments :

  1. I find this blogger an inspiration and is definitely worth following. I've became a subscriber too, so please keep me updated. thanks once again.

    Chuck
    www.gofastek.com

    ReplyDelete
  2. interesting details! keep sharing articles like this. Kudos!

    www.triciajoy.com

    ReplyDelete
  3. You have a wonderful blog. This is really worth to read and it helps a lot of people to learn new information. Please keep on posting. Thank you.

    Sienna
    www.gofastek.com

    ReplyDelete
  4. this java program is awesome stuff. thanks for sharing
    solution manual book

    ReplyDelete
  5. Love it! Very interesting topics, I hope the incoming comments and suggestion are equally positive. Thank you for sharing this information that is actually helpful.


    ufgop.org
    ufgop.org

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete

  11. Having read this I believed it was very informative. I appreciate you spending some time and energy to put this information together. I once again find myself spending a lot of time both reading and commenting. But so what, it was still worthwhile! outlook 365 sign in

    ReplyDelete
  12. Enjoy body massage service in Delhi and NCR through expert female massage therapists. We are the luxury spa based in Delhi and NCR :
    Spa Center in Delhi
    Delhi Massage
    Body Massage Delhi
    Best Spa Delhi NCR
    Massage Center Delhi
    Massage Parlour in Delhi

    ReplyDelete
  13. It is Best article and amazing thank you for sharing amazing article...
    Call Girls in Lahore
    Lahore Call Girls

    ReplyDelete
  14. Amazing Beautiful Article i love this blog post it is best post and your blog post much unique than others blog...

    Call Girls in Karachi
    Karachi Call Girls

    ReplyDelete
  15. Amazing Blog Post and great content keep it up thank you for sharing..

    Packers and Movers in Noida

    ReplyDelete
  16. wow finally i fund it it is best and much better than others blog...

    Escorts in Karachi
    Karachi Escorts

    ReplyDelete
  17. It is best Blog ever i see and it's my favorite blog post...
    Escorts in Lahore
    Lahore Escorts

    ReplyDelete
  18. good work and amazing Article i am huge fan of your this post...
    Escorts in Karachi
    Karachi Escorts

    ReplyDelete