How To Sort TreeSet With Comparable Interface In Java | Set in Java Part - 5 | Java Tutorial

preview_player
Показать описание
In this video, Let's learn about the TreeSet in Java, and How to sort TreeSet With Comparable Interface In Java.

This is part 5 of Set in Java, make sure you watch Parts 1, 2, 3, & 4 of this Set In Java Tutorial to completely understand the important concepts of Set in Java.

Watch Here:

TreeSet(by default elements are sorted in ascending order), where elements are Integer type in Java.

TreeSet is an implementation of the SortedSet interface in Java that uses a Tree for storage.

The ordering of the elements is maintained by a Set using their natural ordering whether an explicit comparator is provided.

To sort TreeSet elements using the Comparable interface in Java first, we create a class Student that implements the Comparable interface.

______________________________________________

Want to learn Coding? or want to learn Computer Languages like C, C++, Java, Python, HTML, PHP, etc. then make sure you Subscribe to @codingseekho

#codingseekho #java #javatutorial #setinjava #hashset #set #javaprogramming #learnjava #javaforbeginners
Рекомендации по теме
Комментарии
Автор

Hlo sir the new start of coding seekho is very very appreciative and your java serise is also very good Thanku so much sir for this hard work. ❤️❤️

sumitkumar.
Автор

Excuse me sir ek doubt hai :
aap bta rhe the ki StringBuffer class ka bhi object bana kr hum string type ka data store kra skte hai
but tree me nhi bcz, TreeSet me data sorted order me hona chaiye ( or StringBuffer ) ke pass compareTo function nhi hai jo wrapper class ke pass hai
but aap ne last me data store StringBuffer ka object bna kr kraya hai tab error kyu nhi aayi

abhishekgurjar_