Last active
August 29, 2015 14:05
-
-
Save shixiaoyu/3d53aa977ea4b29d8930 to your computer and use it in GitHub Desktop.
code1
This file contains hidden or 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
public class TestClass { | |
int a; | |
int b; | |
public TestClass() { | |
a = 5; | |
b = 6; | |
print(); | |
} | |
public void print() { | |
System.out.println(this.getClass() + ": a:" + this.a + ", b:" + this.b); | |
} | |
public static void main(String[] args) { | |
TestClass test1 = new TestClass(); | |
TestClass test2 = new TestClass2(); | |
} | |
class TestClass2 extends TestClass { | |
public TestClass2() { | |
super(); | |
a = 1; | |
b = 2; | |
print(); | |
} | |
public void print() { | |
System.out.println(this.getClass() + ": a:" + this.a + ", b:" + this.b); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment