Hello, in this Java programming video, we are going to look at bit set the bits at class. So it you can pick up a lot in array, but it's a very, very special array in that all it does is whole bit valid, you know, true and false one zero, you know, that sort of stuff. And that's really all there is to illustrate an example. So to use it you need to import import, Java dot util. Asterix, and then you want to do just a bit one equals new bit set and specify the size of it on specify your forward just to keep things simple. And I create number one directly afterwards to this P two.
And now I'm going to do B one, got set and now we can set f ticular index to be true. So if we just specify the index, it will set it to true, or that's fine index and a value and explicit y range as well. I'll provide a link with all the different methods and functionality that you can utilize on bit sets more, sort of keep it simple and just get you into the basic or basic foundations on it. Okay, so set so I'll use second method, where I'll specify the index zero and the value thought that's quite true. I want to just give it four instances of it. 123, so it's gonna be all true.
Something similar for B to now. Okay, that's pretty cool. And let's print out the system winterland let's print out the one that's printed. There we go. Okay, so this has been one like so unless this is something similar for being too well, so we can help identify them. Okay, that's pretty cool.
So if we set this to false, let's see what would happen. It disappeared it because it's not on anymore. So that is what happens. Let's set this back to true. What can you do with it. So this is great if you want to keep track of some bits, maybe for some for data storage.
Also, if you thought if you're going to do some sort of, you know, bit operation like and or XOR, and bitwise objects provide all of that functionality. So we could do B one dot, let's say, and so this one and B one and B two and assign it to B one, B two Now if I were to print out, so only B one will be changed to less than object that coordinate, B two will remain on chain knife and run it. Still the same, because you know the end requires both values to be true. So this and this is true this and this is true, so forth and so forth, which is to a fault. However, the first one's true in B one, but the first one in B two is false. So he should make it false, hence why zero isn't appearing.
Okay? Make this one false. Now. That's pretty cool as well. So let's exceed that is appearing in here as well. And only the ones that are both true, which is one and three are on here.
Now, let me show you another thing that you can do. So I'll comment this out though. Another method that you can choose all the checks if either one of them is on. And because with this one, it's on here, but it's off here. So technically true. It's on in both places for flight if I'm here, but it is still on in one location, that's fine.
On here on here, hence why it provides makes them all true. Let's show the final one x or below case closeable, which means it required one of them to be on but that's it, only one can be true. The other one has to be false. Hence why you get zero to this time, because true and false. That's fine. One of them's true.
For one, they're both true. So it doesn't like that, for instance, that's true, false, true and false fine. So you set it to true and true and true to the like. So you set it to false. That's it for the SEC class. If you have any questions as usual, feel free to reach out there.
There will be a link with this video that will provide more functionality to do bit set for you have any questions again, like I said, feel free to reach out and other quotes in your next awesome Java video.