Saturday, July 17, 2021

How to sort elements of vector object on particular column


Using sort() method on vector object we can sort elements of vector object.
For this purpose we need to create our own comparator.
Steps to follow
1. Create own Comparator class by implementing Comparator interface and define compare method.
2. use vector.sort() method and pass the object of your own Comparator implemented class.
3. finally you vector object will have sorted elements as per your compare() method defined.

Please go through the above video for more in details.


 

Sunday, July 4, 2021

Java Collection #20 | Using Vector Part-2

How to add custom object to Vector?
What is the requirement to be able to search an custom object from vector?
Why and how to override equals() method?

Java Collection #19 | Using Vector


How to use java.util.Vector
How it is different from java.util.ArrayList
Different ways to add or remove elements.

Friday, July 2, 2021

Requirement to use TreeSet for custom object

 

The video explains about

1. How to use TreeSet?

2. What is the requirement for a custom object to be added to Treeset?

3. What is Comparable and Comparator?

4. When and how to use Comparable?

5. When and how to use Comparator?

6. How to iterate the elements added to the TreeSet object?