‫-: Hi. Inside of this lecture,
‫we are going to see what is a set.
‫So there is a data structure called HashSet
‫and it's very similar to arrays
‫but with a big major difference.
‫So it's written like this:
‫set and you can call set with HashSet type.
‫Now the major difference between arrays and sets
‫that a number eight string or any type of value
‫can be present in a set only once.
‫So you cannot have the same value
‫more than once inside of a HashSet.
‫We're going to see what the HashMap is.
‫Now we are interested in HashSet.
‫Okay, so choose, choose HashSet from here
‫and open this angular braces and write String,
‫for example, you can store any type that you want over here
‫and I'm gonna call this mySet
‫and this will be initialized as we did
‫in the ArrayList as well.
‫After that, you can actually add any element
‫that you want like we did in the ArrayList as well.
‫So you can just say mySet dot add,
‫it will expect some string.
‫For example, give James, and over here,
‫add James one more time
‫and in an exact way that you have written.
‫For example, if you have written with an upper case J,
‫then you should write it with an upper case J
‫one more time because over here,
‫I'm going to see the size of mySet.
‫So if you do mySet dot size, it will print
‫out the current numbers of elements inside of your set.
‫You can use this in your ArrayList as well.
‫For example, you can do something
‫like myMusicians dot size over here
‫and you, you're gonna get the number
‫of the current elements inside of your myMusicians list.
‫So if we run this, you will see that in the musicians
‫you get four but in mySet you only get one
‫because you have only James.
‫Even though you try to add James two times over here,
‫you couldn't because set only consists of unique elements.
‫Okay? So there is not much to talk about over here
‫because it's basically the same thing with ArrayList
‫but you can only have one value, only one time,
‫or here it's all unique elements.
‫So we're going to stop here and we are going to continue
‫with the HashMap, which is much more commonly used
‫in under IT application development.