import java.time.Duration;
import java.time.LocalTime;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class JI9049546 {

	public static void main(String[] args) {
		String ss="strength of Java is its simplicity and consistency A language can become an unmaintainable mess if it includes every feature that yields marginally more concise code However in those other languages it isnt just easier to spawn a thread or to register a button click handler large swaths of their APIs are simpler more consistent and more powerful In Java one could have written similar APIs that take objects of classes implementing a particular function but such APIs would be unpleasant to use";
		int counter = 0;
		for(int i = 0; i < 5000; i++) {
			System.out.println("-------------------------------------------------------------"); 
			LocalTime start1 = LocalTime.now(); 
			List<String> ll=Arrays.asList(ss.split(" ")); 
			Collections.sort(ll,new Comparator<String>() { 
				public int compare(String o1, String o2) { 
					return o1.compareTo(o2); 

				}; 
			}); 
			//System.out.println(ll);
			Duration d1 = Duration.between(start1, LocalTime.now());
			System.out.println("Time Taken Without Lambdas:" + d1);
			LocalTime start2 = LocalTime.now();
			List<String> l=Arrays.asList(ss.split(" ")); 
			Collections.sort(l,(a,b)->a.compareTo(b)); 
			//System.out.println(l); 
			Duration d2 = Duration.between(start2, LocalTime.now());
			System.out.println("Time Taken With Lambdas:" + d2);
			System.out.println("-------------------------------------------------------------"); 
			if(d1.compareTo(d2) < 0) {
				System.out.println("Lambdas took more time");
				counter++;
			}
		}
		System.out.println("Lamdas took more time in " + counter + " cases");
	}

}
