Java

Let’s learn how to remove duplicates from arraylist in java. How to remove duplicates from ArrayList in java Here the task is to remove duplicates in ArrayList. In the below java program first get given ArrayList with duplicate integer values. Now print ArrayList with duplicate integer values on the console. Create another ArrayList ‘alNew’. Pass…

Read More How to remove duplicates from ArrayList in java

Let’s learn how to remove duplicates from array in java without using collections. How to remove duplicates from array in java without using collections To remove duplicates from array is bit tricky. Because problem with arrays is not finding duplicates, its about removing duplicates. We all know that an array is a static data structure…

Read More How to remove duplicates from array in java without using collections

Let’s learn difference between while and do while loop in java. Difference between while and do while loop in java While loop do while loop In while loop condition is checked first and then statements are executed. In do while loop statements are executed atleast once and then condition is checked. In while loop statements…

Read More Difference between while and do while loop in java

Let’s learn how to remove last element from arraylist in java. How to remove last element from ArrayList in java To remove last element from arraylist use two overloaded remove() method of ArrayList. They are, Here’s an example on remove(int index) to last element from arraylist. import java.util.ArrayList; import java.util.List; public class ArrayListRemoveLastElement { public…

Read More How to remove last element from ArrayList in java

Let’s learn how to sort TreeSet in descending order in java. How to sort TreeSet in descending order in java In this post lets sort TreeSet elements in descending order or decreasing order. For this we are using descendingSet() method. This method returns a reverse order view of the elements contained in this set. import…

Read More How to sort TreeSet in descending order in java

Let’s learn TreeMap comparator() method in java with examples. Treemap comparator() method in java with examples TreeMap comparator() method returns the comparator used to order the keys in this map, or null if this map uses the natural ordering of its keys. Let’s see example on TreeMap comparator() method for natural ordering. import java.util.Comparator; import…

Read More TreeMap comparator() method in java with examples