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 do you remove duplicates in array without collections in java? 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 what’s the 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…

Read More Difference between while and do while loop in java

Let’s learn how do you 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, remove(int index): accepts the index of the element to be removed. Pass index of last element to delete last…

Read More How to remove last element from ArrayList in java

Let’s learn how do you sort in descending order in TreeSet 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…

Read More How to sort TreeSet in descending order in java