Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting the Objects

Collection Classes

Sorting the Objects

by  koundinya  Posted    (Edited  )
public class SortObjects
{
public static void main(String s[])
{
Collections col;
List l=sort(s);
System.out.println("\nStrings sorted List ...");
for(int i=0;i<s.length;i++)
{
System.out.println((String)l.get(i));
}
int ints[]={11,2,-22,401,6};
Integer in[]=new Integer[ints.length];
for(int i=0;i<in.length;i++)
{
in=new Integer(ints);
}
l=sort(in);
System.out.println("\nIntegers sorted List ...");
for(int i=0;i<in.length;i++)
{
System.out.println((Integer)l.get(i));
}
}
public static List sort(Object o[])
{
ArrayList al=new ArrayList();
for(int i=0;i<o.length;i++)
al.add(i,o);
List list = Collections.synchronizedList(al);
Collections.sort(list);
return list;
}
}



The above program will help the user to sort objects .


Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top