10 Static Methods and Variables

 

After reading lesson 10, you will be able to:

  • Differentiate between static methods and instance methods
  • Understand when to use the static keyword
  • Correctly define static methods and static variables

This lesson introduces the topic of the static keyword in Java.  In Java, using the keyword static indicates that the method is a class method or the variable is a class variable as opposed to an instance method or instance variable.  Every Java application uses the static keyword at least once for the main method:

public static void main(String[] args) {…}

In this lesson I will review the impact of using the static keyword for both methods and variables. In addition, since the keyword final is often used when creating static variables, this lesson reviews the impact of defining static final variables.

10.1   Static Methods

10.2   Static Variables

10.3   Final Static Variables

10.4   Summary