inheritance - Avoid repeated imports in Java: Inherit imports? -
is there way "inherit" imports?
example:
common enum:
public enum constant{ one, two, 3 }
base class using enum:
public class base { protected void register(constant c, string t) { ... } }
sub class needing import use enum constants convenient (without enum name):
import static constant.*; // want avoid line! public sub extends base { public sub() { register(two, "blabla"); // without import: constant.two } }
and class same import ...
import static constant.*; // want avoid line! public anothersub extends base { ... }
i use classic static final constants maybe there way use common enum same convenience.
import
s aid compiler find classes. active single source file , have no relation whatsoever java's oop mechanisms.
so, no, cannot “inherit” import
s
Comments
Post a Comment