
-----------------------------------
alpesh
Mon Jan 26, 2004 12:56 am

sortstring.java
-----------------------------------
/*

WAP To accept more than one string and arrange them in alphabetical order

--------------
public int compareTo(String anotherString)

Compares two strings lexicographically. The comparison is based on the Unicode value of each character in the strings. 

Parameters: 
anotherString - the String to be compared. 
Returns: 
the value 0 if the argument string is equal to this string; a value less than 0 if this string is lexicographically less than the string argument; and a value greater than 0 if this string is lexicographically greater than the string argument. 


*/

import java.io.*;
public class sortstring
{
public static void main(String arg[])
{
int n;
String name[],nS;
n=0;
name = new String[20];
try
{
DataInputStream in;
in = new DataInputStream(System.in);
System.out.println("Enter no of Entry : ");
System.out.flush();
nS = in.readLine();
n = Integer.parseInt(nS);
System.out.println("Enter " + n + " entries ");
System.out.flush();
for(int i=0;i