i have an abstract class that many other classes extend.
They should all import about 7 packages needed, but when i import them in the abstract class and not the subclasses, the compiler errors. Is this not possible or am i just not doing it the right way? thanks!
Imports do not get automagically added to subclasses.
An import simply allows the programmer to use a shorter name for a type (say, List<T>
) rather than the type's fully qualified name (java.util.List<T>
). It does not have anything to do with inheritance.
If you're using an IDE, such as Eclipse, imports can automatically be added for you - but that's still only an IDE function. The source code of every class file must have its own imports (unless you use fully qualified names everywhere, and !@#$ that).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With