Created
December 19, 2018 05:51
-
-
Save jackblack369/303e4f75dba08a3bbd5456868a626ee2 to your computer and use it in GitHub Desktop.
temp snippet
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 A | |
{ | |
int nonStaticVariable; | |
static int staticVariable; | |
static void staticMethod() | |
{ | |
System.out.println(staticVariable); | |
// System.out.println(nonStaticVariable); | |
} | |
void nonStaticMethod() | |
{ | |
System.out.println(staticVariable); | |
System.out.println(nonStaticVariable); | |
} | |
} | |
class MainClass | |
{ | |
public static void main(String[] args) | |
{ | |
A.staticVariable = 10; | |
// A.nonStaticVariable = 10; | |
A.staticMethod(); | |
// A.nonStaticMethod(); | |
A a1 = new A(); | |
A a2 = new A(); | |
System.out.println(a1.nonStaticVariable); | |
System.out.println(a1.staticVariable); | |
a1.nonStaticMethod(); | |
a1.staticMethod(); | |
System.out.println(a2.staticVariable); | |
a1.staticVariable = 20; | |
System.out.println(a2.staticVariable); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment