The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
September 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

sorting answer

Posted by swapnil on November 16, 2000 at 10:00 AM

hi salil,
i have not understood ur question completelly . but wht i interprete is u need to sort all ur records sometimes by city or names or something like that . isn't it? if that's what u r looking for go through the code below . it may help u.
.................................................................


import java.util.*;
public class ascending
{
public static void main(String[] args)
{
TreeSet ts=new TreeSet();
for(int i=0;i {
ts.add(args[i]);
}
String myarr[]=new String[ts.size()];
Iterator myiter=ts.iterator();
int index=0;
while(myiter.hasNext())
{
myarr[index]=(String)myiter.next();
index=index+1;

}
System.out.println("The sorted names are :");
for (int i=0;i {System.out.println(myarr[i]);
}

}
}
..............................................................

Note here the input names are through the command line but in ur case they may be through the database.
try the code for ur appllication.
hope this helps.
regards,
swapnil



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us