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.

imports aid compiler find classes. active single source file , have no relation whatsoever java's oop mechanisms.

so, no, cannot “inherit” imports


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -