Last active
December 18, 2019 06:26
-
-
Save SansWord/c527507d0f7f062da62a71faf0cb9077 to your computer and use it in GitHub Desktop.
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
package com; | |
import java.lang.invoke.MethodHandles; | |
public abstract class TestStatic { | |
private static Class classInstance = MethodHandles.lookup().lookupClass(); | |
public Class getClassInstance() { | |
return classInstance; | |
} | |
public static void main(final String[] args) { | |
System.out.println(new A().getClassInstance().getCanonicalName()); | |
System.out.println(new B().getClassInstance().getCanonicalName()); | |
System.out.println(new C().getClassInstance().getCanonicalName()); | |
} | |
} | |
class A extends TestStatic { | |
} | |
class B extends TestStatic { | |
} | |
class C extends A { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wondering is there any way to change behavior to make A, B, C to have different name.
But I still want to make the variable static. Or at least one instance each class rather than each instance.