‫Welcome back.
‫In this video, we are going to check out autos and locals and also breakpoints a little more.
‫So we saw how to use breakpoints in the last video and we created this one breakpoint at the point where
‫we create this local list or this local variable called friends, which is only available in our main
‫method.
‫And then we can, of course, go ahead and create some more of those breakpoints.
‫So I'm just going to create two breakpoints.
‫Now, let's say we want to have a look at our breakpoints.
‫And in this example, it's super easy because we only have those two breakpoints, right?
‫So they are visible all the time.
‫But now imagine we did this.
‫So we have summed it up.
‫We really just want to break it down on the higher level.
‫And now we only see this one breakpoint.
‫But where are all the other breakpoints?
‫Well, what you can do is you can start.
‫And then or start debugging by pressing a five.
‫And then the other thing that you can do is you can check out your breakpoints.
‫So control alt b is the shortcut or you can just go to Windows breakpoints here from debug debug Windows
‫breakpoints.
‫And that will open up this little tab here, which shows you the different breakpoints that you have.
‫So we have a breakpoint in program, CSS line ten, character 13 and another one in program CSS line
‫21 for character 13.
‫All right.
‫So these are the two breakpoints that we have.
‫And now in order to get rid of a breakpoint, what we can do is, of course, we can press on the breakpoint.
‫So here on the left hand side, we can click on it.
‫And as you can see, it completely disappears from our breakpoints.
‫Once we do that, we can also just deactivated breakpoint.
‫Now you can see it's white in the middle.
‫So let me do that with this breakpoint here.
‫You can see it better.
‫You can see now it's not fully red anymore.
‫It's not filled with red anymore.
‫It's filled with white.
‫All right.
‫So it's still there, but it's deactivated.
‫So you can deactivate breakpoints any time with this window.
‫With this breakpoint window.
‫All right.
‫So this might not be useful in our specific case here because it's a super short program.
‫Right.
‫We don't have too much going on here.
‫But once you have a program where you have breakpoints in many different files, this comes in handy
‫and it really helps you out there.
‫All right.
‫So the next thing that I would like to show you, and that's a very important one, especially to figure
‫out where your bugs lie and that's to use locals and orders.
‫All right.
‫Let's start with orders.
‫You can see we have this new window here called orders.
‫Orders will automatically show us the variables which are around the current breakpoint so the ones
‫that are relevant currently.
‫So there's this args variable, which is this one here at the top from our main method.
‫So this args variable and then we have this friend's variable which currently is null.
‫And once we go to the next step, so we step over.
‫We can see that now.
‫We have friends and party friends.
‫So all those shows us automatically the variables that are surrounding the breakpoint that are close
‫to where we are currently.
‫All right.
‫So here I'm with friends and you can see that we have seven entries there.
‫And then we have party friends, which is at this point null.
‫But once we step over, we can see now party friends is what is looked at.
‫All right.
‫So we have this variable count and we have this variable party friends, which has some additional information.
‫You can see the count of party friends is zero at this point.
‫You can see the type here if you want to know more about it, it's a system collection list.
‫And then we have this party friends count, which is also zero.
‫All right.
‫So Count, which is this one here and this one over here.
‫And then we have party friends, which has a count of zero.
‫All right.
‫So that's the general idea or actually party friends.
‫And then we have count.
‫So it's two different things.
‫As you can see, there is the party friends count, which is the amount of party friends and there is
‫the party friends list, which is the list which currently doesn't have any friends in there or any
‫entries in there.
‫All right.
‫So that's our autos.
‫And it's super handy when you are looking at variables that you currently have right now.
‫Now, what you also can do is you can modify those.
‫All right.
‫So you could modify the value here.
‫You could go ahead and enter five and test how your program behaves once you change the value to a different
‫value.
‫As you can see, I've changed it to five and now I could see, okay, how would my program behave once
‫I add a or enter a value of five, for example?
‫All right.
‫So that's one thing.
‫The other one that I would like to show you are locals.
‫But before we do that, I would like to show you the watch first.
‫So let's go to the watch and watch opens up this.
‫One note, which looks similar to what we have just seen.
‫And now you can add items to watch, by the way, at the bottom.
‫Autos is still there, so it's just a new tab here at the very bottom.
‫And here is watch one.
‫That's because, well, breakpoints has taken some space and it's important.
‫But what we can do is we can at any point we can drag out all those and have it at the side here so
‫we could compare them.
‫So let's say I want to add my friends, so I'm just going to add party friends to my list.
‫All right.
‫Party friends entered and you can see the party friends count is zero.
‫Then it's always important to where you are right now.
‫So at this point, I'm over here, so I'm just going to look at Current Friend and let me enter.
‫As you can see, I'm getting an error name.
‫Current Friend does not exist in the current context, so it doesn't exist at that point yet, but it
‫will exist later on.
‫So let's also look at friends because friends is also something that doesn't exist in the current context.
‫Why is that?
‫Well, because right now, as you can see, the arrow is within my get party friends.
‫So we're within this method.
‫Now, the scope of our whole variables is within this method and this friend's variable and this party
‫friend's variable.
‫They are not available in here.
‫So this is not the party friends that we're looking at here.
‫All right.
‫Because the party friends that we're looking at is this one here.
‫Why is that?
‫Well, it's because of scope.
‫All right.
‫Scope is a very important concept, because a variable that is created within a method is only available
‫within that method.
‫That's why we can't use friends or party friends from our main method within our get party friends,
‫because it's a different method, right?
‫If we created them globally.
‫So if we created them here at the top as fields for our class, then they would be available in all
‫of the methods.
‫All right.
‫So that's really important here.
‫I looked at into scope in another video, I think.
‫But here it's really, again, very easy to see because, well, we can directly see the values that
‫we get.
‫All right.
‫Now, let's go ahead with the program and let's just.
‫Continue.
‫Let's just say, okay, let's continue.
‫You can see now party friends and current friends are available because now current friend is null.
‫So we can just go to the next step and we can see that the current friend is Michele.
‫So our program gives us those values and at the same time at the right hand side, all those constantly
‫gives us the closest values, values that are closest to the breakpoint that we are at right now.
‫All right.
‫So once I jump out and I jump out again.
‫And then I see I'm at friends, so I had to jump up multiple times.
‫But now I'm in the main method again because I jumped out of my get party friends and now party Frances.
‫Now my current friend is Carlos and my friends is the count of two, so I only have two friends in my
‫list.
‫Now that's a weird one because I thought I had seven friends in my list.
‫Well, that's something that we have to look into in a little more depth, because what we're doing
‫is a huge mistake and it's a very beginner kind of mistake we are removing from a list now we're passing
‫by reference, we're not passing by value, and that's something that we will look into in the next
‫video just as a little preparation for you.
‫So and then before we do so, I would like to check out another window.
‫And as you can see, there are plenty of windows.
‫So you can learn so much about debugging.
‫If you just check out the different windows and see where your program is at every single line and what
‫the state is.
‫And you can also check out the memory and so forth.
‫But what's important for now is the locals.
‫So I would like to show you locals.
‫Locals shows you the variables that are available in the local context so in the scope that we're currently
‫looking at.
‫So as I just said, the scope is the method that we're in.
‫So let's start it again.
‫Let's start debugging.
‫And by the way, you could once it's debugging, you can also restart debugging by pressing this button
‫over here, the restart button or by pressing control shift.
‫F five So in the current context, that's the local window where it's important.
‫We're currently at locals, not at Otto's.
‫We're currently looking at locals.
‫So we have arcs, which is this main arcs, the string out here, this string list or array.
‫And then we have our friends and we have our party friends.
‫So these are the variables that are available within this main method, and that's why we are currently
‫being displayed, those two values.
‫So we can step over, we can see, okay, we have seven friends, we can look at our party friends,
‫we can see a count is zero, but the count variable itself is four and we have list.
‫So now we're not looking at friends anymore, but we're looking at the list.
‫So what is list?
‫Well, list is this variable that was passed to us.
‫So you can see here this list was passed to us and this list has a count of seven.
‫All right.
‫And what's in there?
‫Well, there are all of the different names that we have.
‫All right.
‫So that was locals, autos and breakpoints.
‫And in the next video, we are going to fix our back because we still have our bug in here because we're
‫checking for the wrong value.
‫But at the same time, we're going to see how to fix some other problems that we have in our program.
‫All right.
‫So see you in the next video.