This is going to feel like a bit of a switch, and it is a bit of a switch. We're going to be talking about different ways in which we can either use classes completely by going back to the Math class and then ways in which we can have variables and methods that don't relate to a particular object of a class, not a particular person or a particular student. So this will be a little weird and honestly there's a lot of details that we can go into about in been reality which really is these two different ways and we'll focus on that. But we are talking about static variables and methods. So static in this case means one copy for the entire class and we'll see what that means and then programming challenge is basically a riff off of last programming challenge. We made a song object and then we had versus on it and we're going to see that was a really maybe the best design for that. We didn't does we'll see. Okay. So what does this really mean? So static variables and methods are those that are defined in a class, but they don't necessarily, they're not created a new one for each object, especially variables is what you'd be thinking about there. There's actually just one copy of that variable for the whole class. One of the ways we've seen this before and this is how the book starts early page starts off is we've seen the Math class. The thing that's really different for students and for us is that instead of creating a new object and then calling a method on the object, we're going to use the class name and we don't have to create any object and we've seen this before, if you remember, Math.random. Basically in this case, the reason we encapsulate all of these same methods into a class if they don't have particular belonging to an object, it's just a way of organizing them and accessing them. Relocate there's lots of useful methods in math. It's not like you have to have a math object to do anything. They just do stuff. So at the very top they go over and show you the generic ways in which we would declare these things. Again, you could skip ahead to the examples if you want. But really the key things I want to point out here is in the top, the top two red boxes. Whenever you're going to have a staticVariable name, be public static, it could be private static, but static goes in between the public or private term, the Visibility term, and the type. Similarly, with maths then you know wherever because public static void main, right? That's because main is never called on an object. Static can be appropriate for other methods like random because we don't need an object to call it on there. Again, when we're writing our own static methods, we'll put the modifier or the public visibility, which is usually going republic, and then static to say this doesn't require a particular object to do its job. These are, I think, really hard to actually understand without an example, you might want to skip ahead to that. That's down here at the bottom they say, ''The other thing kids need to remember is we use this className.'' That's true if you are trying to access the static variables and methods outside of the class. So notice in the top versus public class name, that might be like public song and then it opens and closes. They're showing you this in the same file. You'd almost never have that. You'd actually be using it in another file, like you weren't actually writing code in the Math class when you are using those math static method, you were writing it in your own class, right? Or your own mean, okay. So when you are trying to use the static variables or methods outside of the definition of a class, then you need to put the className and the header. But I mentioned this because when we get to the programming project at the end, you're going to see we're doing it all within the song class and we're not going to have to have className, although it would be okay if you did. All right. The paragraph right below that first exemplar of this how we do. I just don't think this makes sense to talk about now, it's true. You could probably read every word in here and be like, I can parse what that says, but why and what does it really mean for you? I would say all of these things are true. It's almost never an actual issue when we're designing our own classes and if anything, I would test this at the very end as I like, oh, by the way, after you've even done the programming project, etc, now that we've understood a little bit about how static classes work, let me just mention this following thing, which basically is static methods in a class can't access the non-static instance variables. So because they don't have a particular object that they're working on. But again, come back to this later. The rest of the page really gets into like how we actually use these things and we already talked about one way, which is a lot of times we might make a class that has only static things in it. Maybe some static variables like constants like Pi or speed of sound or speed of light or whether those things and then a bunch of methods that just do useful things with just those constants or maybe perimeters layer pass to them like Math.random. What we're going to focus on on this page and will be useful for the API free-response questions is, how do we use static variables within what we would more think of as a normal class? We're going to look at person and maybe a few others. Here's person. So this is the first example, really might go ahead and skip to this. Let's just remember, look at the top public class Person has three private instance variables, and those are the same ones we've always had for every object you create of class Person, they should have their own name, their own e-mail, their own phoneNumber. What we're going to introduce now is in that red box, is static variable for the only one exists for the entire class, there's not one for Beth and one for Susan and one for Maria and one for Jose. There's only one and basically I only use them for one thing, I think certainly an introductory programming and maybe in all of undergraduate education, we would only use these for one thing and that will have one other thing, is to basically keep track of the number of objects that you've created. So maybe every time I want to create a new object, I want to like update this personCounter be like, oh, I've created 40 objects so far, 40 people in my class so far. So what that means is we would create that public static int personCounter, set it equal to 0. Because when we start off, we want no, we have now created no objects of class type person and then they're not every constructor that we have, we'll do our regular constructor things of assigning values to all the instance variables and we're also going to update our static class variable. Okay. This isn't one per object remember, is one for the entire class. That just keeps this if you speak old school computer science global variable that which is not a term and in Java, but it keeps track of the total number of times we've called the constructor essentially. I've never done this, but I can imagine this one, that one other thing you could do be like, so for class temperature, maybe I want to keep track of the maximum or maybe it's the minimum. I don't know, maybe you want to do both. Temperature ever created. Those makes sense. So here, in addition to our, again, our regular instance variable temperature, we're going to have public static double maxTemp equals 0. Zero maybe not the best choice for that. Like what if you live in the Alaskan temperatures? Well, now they get above 0, but maybe they never used to get above zero, maybe that should be the minimum integer.min value, the minimum possible number ever and then that way anything you enter, it would probably be bigger than that and that will be your real maximum temperature. Then again in the constructor it's like, hey, this is the maximum temperature you've ever constructed. Now maybe if you have a method that changes the temperature, maybe you would need to make have that check there as well. Depends on what you wanting to keep track of is the maximum ever constructed or the maximum you've ever set an object to.