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.



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

Answer / 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

More Core Java Interview Questions

What are meta-annotations?

0 Answers   Cyient,


What is serialization in java?

0 Answers  


For technical interview question please sir send me because tomorrow my interview

1 Answers   FactSet Systems,


Can we call the run() method instead of start()?

0 Answers  


What is the function of http?

0 Answers  


Default layout of panel and frame?

3 Answers  


Same common question what is Map,Set,HashMap,List????

4 Answers   Symphony,


In Java, what are this() and super(), and where are you required to use them?

2 Answers  


How do you decide when to use arraylist and linkedlist?

0 Answers  


why abstract class will have a constructor?

4 Answers  


How to perform merge sort in java?

0 Answers  


What is a void in java?

0 Answers  


Categories