Posts

Showing posts with the label Java 12

All advanced sorting techniques using Java 8 and Streams

package com.dpq.interview.Q; import java.math.BigInteger; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.List; public class SortingDemo { public static void main(String[] args) throws ParseException { allSortingTechniquesAfterJava8(); } public static void allSortingTechniquesAfterJava8() throws ParseException { List<Employee> list = populateList(); System.out.println(“####################################### Natiral soring by Employee Id ###############################################”); list.stream().sorted().forEach(e -> System.out.println(e)); System.out.println(“####################################### Natiral soring by Employee Id but in desending order ###############################################”); list.stream().sorted(Collections.reverseOrder()).forEach(e -> System.out.println(e)); List<Employee> sortedList = list

Java 12 Features

1.Java 12 Features 2.JVM Changes JEP 189 – Shenandoah: A Low-Pause-Time Garbage Collector (Experimental) JEP 346 – Promptly Return Unused Committed Memory from G1 JEP 344 : Abortable Mixed Collections for G1 JEP 230 and 344 JEP 341 Default CDS Archives 3.Language Changes And Features Switch Expressions (Preview) File.mismatch method Compact Number Formatting Teeing Collectors Java Strings New Methods JEP 334: JVM Constants API JEP 305: Pattern Matching for instanceof (Preview) Java 12 Features Some of the important Java 12 features are; JVM Changes – JEP 189, JEP 346, JEP 344, and JEP 230. Switch Expressions File mismatch() Method Compact Number Formatting Teeing Collectors in Stream API Java Strings New Methods – indent(), transform(), describeConstable(), and resolveConstantDesc(). JEP 334: JVM Constants API JEP 305: Pattern Matching for instanceof Raw String Literals is Removed From JDK 12. Let’s look into all these Java 12 features one by one.