public class DynamicSorting
{
    public static void main(String[] argv)
    {
        long t1, t2;
        int max = 1000000;
		
        t1=System.currentTimeMillis();
        TreeSet mySet = new TreeSet();
        for(int i=0; i<max; i++){
            mySet.add("ABCDEFG"+Math.random()*100000);
        }		
		
        t2=System.currentTimeMillis();
		
        Runtime rt = Runtime.getRuntime();
        long memoryUsed = rt.totalMemory() - rt.freeMemory();
        System.out.println(mySet.first());
        System.out.println("Time consumed="+(t2-t1)+" (ms)   Memory used="+memoryUsed+ "(bytes)" );
    	
    }
}