Created
March 21, 2014 07:59
-
-
Save sivabudh/9681632 to your computer and use it in GitHub Desktop.
The difference between static and non-static
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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