Posts

Showing posts with the label static method

Java Static Keyword (static variable, static method, static block)

Image
Java static Keyword: static Variable, static Method, static Block (With Examples) ✨ Quick Summary In this post, you’ll learn what the static keyword means in Java. We will cover static variables , static methods , and static blocks with simple beginner-friendly examples. Java static OOP In our previous post, we learned about Access Modifiers . Now, let’s learn one of the most important Java keywords: static . 1) What is static in Java? The static keyword means the member belongs to the class , not the object. That means: ✅ static variables are shared by all objects ✅ static methods can be called without creating an object ✅ static block runs automatically when class loads 2) static Variable in Java A static variable is shared among all objects of the class. ...