import java.util.*; public class example2 { public static void main(String[] a) { LinkedList cs = new LinkedList(); // code to add elements cs.add( "data" ); cs.add( "element" ); cs.add( "boolean" ); cs.add( "computer" ); cs.add( "algorithm" ); // Here’s the one-liner (excellent!) to sort that list: Collections.sort( cs ); System.out.println("lexicographic order: " + cs ); } }