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

72 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
  19. The Most Popular Agency to Find Elite and Classic Escorts in Jaipur Welcome to the neharani.com of Jaipur most responsible and well known female escort in Jaipur organization.
    Jaipur Escorts
    Jaipur Escorts Agency
    Jaipur Escorts
    Udaipur Escorts
    Durgapura Escorts
    Jagatpura Escorts
    Jodhpur Escorts
    Surat Escorts
    Pune Escorts

    ReplyDelete
  20. Are looking for model and independent call girls escorts in Chennai where your on business, get-away, occasions, hot and happening stay Escorts Girls in Chennai then Sexy Chennai Escorts is the most ideal approach to scan for escort service in Chennai. You will utilize this Chennai Escorts site page as a snappy and straight forward to find females closest to your area in Chennai. We have been in business here in Chennai since 2003. From the begin we have direction ourselves to the following dimension of business see than exchange escort in Chennai. We are intense regarding what we are doing in Sexy Chennai Escorts. The Chennai Escort Service offered by Sexy Chennai Escorts site are entirely for entertainment purposes.

    Chennai Escorts
    independent Escorts in Chennai
    Chennai Escort Agency
    Chennai Escort
    Escorts in Chennai
    Call Girls in Chennai
    Chennai Escort Service
    Independent Chennai Escorts
    Russian Escorts in Chennai

    ReplyDelete