This article was featured on the Main Page LinkFA-star
A method or void is a piece of code which can be called upon to:

  • Change a variable
  • Call upon other voids
  • Write to a file
  • Create a new file

Difference between a void and a static void

A static void cannot call upon a specific instance inside the class (e.g. cannot use "this." to refer to something). To clear things up, here is an example:

public class ExampleClass {

public static void StaticExample()
    // static method code
 public void InstanceExample()
    // instance method code here
    // can use THIS


So, "static" must be put before "void" when using a static void, whereas you only need to put "void" for a normal one.


// Static method is called -- no instance is involved

ExampleClass.StaticExample(); // Instance method is called

ExampleClass objMyExample = new ExampleClass();

objMyExample.InstanceExample(); </source>

This shows what I mean when I say you cannot use this, etc.