Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to Sort list of Strings in ascending order without using
java api.

Answer Posted / megha

package practise;

import java.util.Scanner;

class Sorting {
public static void main(String[] input)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the count :\t ");
int k=sc.nextInt();
String temp=new String();
String names[]=new String[k];
System.out.println("enter the names");
for(int i=0;i<k;i++)
{
names[i] = sc.next();
}
for( int i=0;i<k;i++)
{
for(int j =i+1;j<k;j++)
{
if(names[i].compareTo(names[j])>0)
{
temp = names[i];
names[i] = names[j];
names[j] = temp;
}
}
}
for(String name:names)
{
System.out.println(name);
}
}
}

Is This Answer Correct ?    25 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why generics are used in java?

1053


Is java 11 paid version?

985


What is the base class of all exception classes in java?

1058


how do I create a runnable with inheritance? : Java thread

980


What happens if we override only equals?

973


What is identifier give example?

1034


What does three dots mean in java?

1126


Explain about oops concepts.

1123


What is the byte order of byte buffer?

1024


Explain about the performance aspects of core java?

1056


What are data types in programming?

992


Which class contains a method: cloneable or object?

1041


Which is the class in java?

1054


How do you implement tree mirroring in java?

1079


What is the function of static in java?

1080