Skip to content

PRO TIP Block youtube.com at the DNS level — Pi-hole, NextDNS or your hosts file — but allow youtube-nocookie.com and i.ytimg.com. These tutorials keep playing; the rabbit hole does not.

Learning without distractions

#93 Set in Java

155.8K views on YouTube

Check out our courses:

Mastering Agentic AI with Java : https://go.telusko.com/agentic-ai
Coupon: TELUSKO10 (10% Discount)

DevOps Bootcamp: https://go.telusko.com/complete-devops
Coupon: TELUSKO10 (10% Discount)

Master Java Spring Development : https://go.telusko.com/learn-master
Coupon: TELUSKO10 (10% Discount)

For More Queries WhatsApp or Call on : +919008963671

website : https://telusko.com/

Udemy Courses:

Java Spring:- https://go.telusko.com/Udemyjavaspring
Java:- https://go.telusko.com/udemyteluskojava
Spring: https://go.telusko.com/udemyteluskospring
Java For Programmers:- https://go.telusko.com/javaProgrammers
Python : https://go.telusko.com/udemyteluskopython
Git : https://go.telusko.com/udemyteluskogit
Docker : https://go.telusko.com/udemyteluskodocker

Instagram : https://www.instagram.com/navinreddyofficial/
Linkedin : https://in.linkedin.com/in/navinreddy20
WhatsApp : https://go.telusko.com/whatsapp
TELUSKO Android App : https://go.telusko.com/TELUSKOAPP
TELUSKO IOS App : https://apple.co/3SsgmU2
Discord : https://discord.gg/D8hWe9BqfF

In this lecture we will learn:
– Set interface in the collection
– Syntax of set interface
– HashSet and TreeSet in a set collection
– Iterable interface in Collection
– How to use an iterator for iterating values

#1
The collection interface is also extended by the set interface.
– List in the collection supports repeated values. The set is an interface in Collection that supports only unique values.
– Package set in the collection is java.util.Set;
– Set extends collection but the class which implements set is different and the class name is HashSet.
– We can define its datatype through generics as well such as greater then bracket Integer less then bracket

#2
– Set also uses the add() method to insert the values in a set.
– Set does not print the repeated values. It prints the same value only one time.
– Set does not maintain the sequence, it gives values in any random order. The set does not sort the values
– Set also does not support an index for values.

#3
– Instead of using the class HashSet, if we will use the TreeSet, it will give values in sorted order.

– All the elements in a TreeSet are sorted as it extends AbstractSet and implements NavigableSet and further NavigableSet extends Sorted Set.

#4
– Collection interface extends an Iterable interface through which we can iterate between the elements by using enhanced for loop, etc.
– Iterable interface contains a method called iterator().
– Iterator returns an iterator object that got all the values from a set. It can be in place of loops.

– It has also a method called next() that gives the values of the next element.
– It has a method hasNext() that helps the loop to know that the set contains a value of the next element.
while(values.hasNext())
System.out.println(values.next());

Github repo : https://github.com/navinreddy20/Javacode.git

More Learning :

Java :- https://bit.ly/3x6rr0N
Python :- https://bit.ly/3GRc7JX
Django :- https://bit.ly/3MmoJK6

JavaScript :- https://bit.ly/3tiAlHo
Node JS :- https://bit.ly/3GT4liq

Rest Api :-https://bit.ly/3MjhZwt
Servlet :- https://bit.ly/3Q7eA7k
Spring Framework :- https://bit.ly/3xi7buh
Design Patterns in Java :- https://bit.ly/3MocXiq
Docker :- https://bit.ly/3xjWzLA

Blockchain Tutorial :- https://bit.ly/3NSbOkc
Corda Tutorial:- https://bit.ly/3thbUKa
Hyperledger Fabric :- https://bit.ly/38RZCRB

NoSQL Tutorial :- https://bit.ly/3aJpRuc
Mysql Tutorial :- https://bit.ly/3thpr4L

Data Structures using Java :- https://bit.ly/3MuJa7S
Git Tutorial :- https://bit.ly/3NXyCPu

Donation:
PayPal Id : navinreddy20
https://www.telusko.com