Skip to content

Instantly share code, notes, and snippets.

@sivabudh
Created March 21, 2014 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sivabudh/9681632 to your computer and use it in GitHub Desktop.
Save sivabudh/9681632 to your computer and use it in GitHub Desktop.
The difference between static and non-static
class Untitled {
public static void main(String[] args) {
// Static method
add2(1, 4);
// Non-static method
Untitled object = new Untitled();
object.add1(1, 4);
}
public double add1(int x, int y)
{
System.out.println("add1");
return 0.0;
}
public static double add2(int x, int y)
{
System.out.println("add2");
return 0.0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment