Skip to content

Instantly share code, notes, and snippets.

@jackblack369
Created December 19, 2018 05:51
Show Gist options
  • Save jackblack369/303e4f75dba08a3bbd5456868a626ee2 to your computer and use it in GitHub Desktop.
Save jackblack369/303e4f75dba08a3bbd5456868a626ee2 to your computer and use it in GitHub Desktop.
temp snippet
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