Home Tutorial Java Corejava Java static method example


Share on Google+Share on Google+
Java static method example
Posted on: April 9, 2010 at 12:00 AM
This tutorial demonstrate the use of static method and static variable.


Static variable are used within the static method. Non static variable do not exits in the static method. Static variables are shared by its class instances. Static variable can be used without using the instances of that class.This can be seen in the below program.


class StaticMethod {
  static int j = 0;

  static void getVariable() {
    System.out.println("Value of static variable j is"+j);

class TestStatic {
  public static void main(String args[]) {


Value of static variable j is 1


Related Tags for Java static method example :

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 9, 2010

Recommend the tutorial

Advertisements Advertisements