From the course: Object-Oriented Programming with Java

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

What is static?

What is static?

- So, what is this mysterious word, static? You've probably noticed it on your main methods already. In English, static means that something is fixed or stationary. In Java, it means that it's fixed to a class so that it can't be personalized by any instances of that class. For example, say we have a static variable laptop that's part of a programmer class. All programmer instances have to share the same static laptop, so when the laptop's edited by any of the programmer instances, it changes for all of them. You can put the static keyword in front of methods or variables, or you can have static blocks of code. If it's in front of a method, it means that you don't need an instance to invoke it. But also, you can't have access to any of the instance variables because it's attached to the class itself. It lives outside of the world of instances. It's like a barren planet where there's no life to interact with.…

Contents