Jan 02

Statics.java Demonstrates static and non-static methods.

 
*/

public class Statics {
 public static void main(String[] args) {
    staticMethod();
    Statics s1 = new Statics();
    s1.regularMethod();
  }

  public static void staticMethod() {
    System.out.println("This is a static method.");
  }

  public void regularMethod() {
    System.out.println("This is a regular method.");
  }
}

Note: Brought from our old site: http://www.salearningschool.com/example_codes/ on Jan 2nd, 2017

Skip to toolbar