Java

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, remove(int index): accepts the index of the element to be removed. Pass index of last element to delete last element.…

Read More How to remove last element from ArrayList in java

Let’s learn difference between HashSet and TreeSet in java. Difference between hashset and treeset in java HashSet TreeSet hashset do not maintain any order. sorted according to natural order. If not use compareTo() method. uses equals() method for comparison. uses compareTo() method for ordering two objects. hashset is implemented using HashTable. TreeSet is implemented using…

Read More Difference between HashSet and TreeSet 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