Interface with default method
public interface InterfaceDefault { default void foo(){ System.out.println("Calling A.foo()"); }
array parallel sort
int[] myArray=new int [10]; for (int i=0;i<10;i++) myArray[i]= (int) (Math.random()*100); Arrays.parallelSort(myArray);
lambda expressions
Runnable java8Runner = () ->{ System.out.println("I am running"); }; java8Runner.run();
new timer type
ZoneId zone = ZoneId.of("Europe/Berlin"); Clock clock = Clock.system(zone); System.out.print(clock.millis()); LocalDate date = LocalDate.now(); System.out.printf(" %s-%s-%s", date.getYear(), date.getMonthValue(), date.getDayOfMonth() );
Stream and paralllel stream like groovy closures
Function<Person, Job> mapPersonToJob = new Function<Person, Job>() { public Job apply(Person person) { Job job = new Job(person.getPersonId(), person.getJobDescription()); return job; } }; java.util.function.Predicate<? super Person> p1 = e -> e.getPersonId() < 6 ; java.util.function.Predicate<? super Person> p2 = e -> e.getPersonId() < 3 ; boolean intMap = persons.parallelStream().allMatch(p1); System.out.println("value:"+intMap); List <Person> persone = persons.parallelStream().filter(p2).collect(Collectors.toList()); List<Job> jobs = persons.parallelStream().map(mapPersonToJob) .collect(Collectors.toList()); Job job = mapPersonToJob.apply(person);