Stats

227 Contributors: 11 Friday, May 26, 2017
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap

Using the static keyword

Syntax

  • public static int myVariable; //Declaring a static variable
  • public static myMethod() { } //Declaring a static method
  • public static final double MY_CONSTANT; //Declaring a constant variable that is shared among all instances of the class
  • public final double MY_CONSTANT; // Declaring a constant variable specific to this instance of the class (best used in a constructor that generates a different constant for each instance)

Related Examples