Articles, Home

Java Array Deep Copy Example – HowToDoInJava

Learn to create deep copy of an array in Java with example. We will be using Apache Commons Lang library and it’s utility class org.apache.commons.lang3.SerializationUtils to array deep copy. Array Deep Copy Example A deep copy of an array will have all objects and it’s referred objects – created fresh. References from old array will …

Articles, Home

Java Sort String Characters Alphabetically – HowToDoInJava

Java example to sort characters of String in alphabetical order – using Stream.sorted() and Arrays.sort() methods. 1) Sort string with Stream API Example of sorting the characters of string using Stream.sorted() API. 2) Arrays.sort() Example of sort a string using Arrays.sort() method. Drop me your questions in comments section. Happy Learning !! Reference: Stream.sorted() Java …

Articles, Home

Java Sort Collection – Collections.sort() – HowToDoInJava

Learn to use Collections.sort() method to sort collections in java with examples. By default, this method sorts the unsorted list into ascending order, according to the natural ordering of its elements. 1) Collections.sort( list ) It sorts the specified list into ascending order or their natural order. All elements in the list must implement the …

Articles, Home

Java Sort ArrayList of Objects – HowToDoInJava

Java examples to sort list of objects or primitives (e.g. int, long) using List.sort(), Collections.sort() and sorting with Java stream API. Examples of sorting in natural and reverse order as well. 1) Sort list of objects Examples to sort an arraylist of objects using different sorting techniques. 2) Sort list of primitives Examples to sort …

Articles, Home

Java Stream Collectors – eProgrammerz

Collectors is class an implementations of Collector that implement various useful reduction operations, such as accumulating elements into collections, summarizing elements according to various criteria, etc.