 Hey everybody, this is Brian. Today we'll be discussing the for loop. Another loop, whoops. And it comes in a couple different flavors. The first one we'll look at is just the standard for loop. And it has a very simple syntax. For, parentheses, and then a code block. Throw in a couple semicolons in there. And you see that that is a valid for loop. We'll actually loop infinitely and just keep going and going and going. To test this, we're going to do system.out.printLine. And we will say int x equals 0. We're just going to print something out. You'll see that it just keeps going and going and going. Now we want to add some intelligence into this. So we will actually throw int x up here. And we will say for x equals 0. And we will say x less than 10. And then x plus plus. Or we're going to increment it. So what we're really doing here is we're splitting this into three parts. We're saying we have an integer named x. We're saying the initial value of x is 0. And then we're saying the condition is while x is less than 10. And then we're going to increment x on each iteration of this. So when we run this, you'll see that it goes 0 through 9 and stops. This may look confusing. I'll give you that. It's confusing. The first time I saw it, decades ago, I was a little confused. But really all you need to know is there's three parts. The beginning, how often, and what to do. So you've got, you're setting the initial value of x. How long you should perform that. Whoops, my gaming mouse. So we're saying while x is less than 10. And then each time we go through this loop, we're going to increment x by 1. You can decrement or do whatever you want. But that's the basic for loop. Now you might be wondering what you'd want for loop for. Well, for loop is handy. Let's say you've got five people you're working with. Well, you can loop, you know, person 1 through 5. Or I'll give you a better example right now of enumerations. We cover any nums and we're just going to use animals. And we'll use the familiar bird, cats, dogs. And we will use the other version of the for loop, which is the shorthand of four for each. We'll say four. And then you'll say animals. M type. And then we will say inanimals. And we're going to save values. Now you notice how we're actually calling the enumerator animals. We're saying animal. Yes, enumerators like everything else in Java are objects. And this object has values, which will return an array of animals. Which I don't think we've covered arrays yet, but we'll get there. Basically, all you need to know at this point is that it returns a group of animals. And what this will do is say for each type or each animal in the animals enumeration bird, cat, dog, we're going to print out that item. So we will say mtype.toString. We run that. We see sure enough, it spits out birds, cats, dogs. It gets this enumeration and it says for each mtype, this variable, which is an animal, print each one of these out. All you need to know really is there are two types of fours. The basic for loop and the for each. You can tell if it's for each because it'll have this colon in the middle. And the basic for loop has three parts. This is Brian and I thank you for watching. I hope you found this video educational and entertaining.