0

I have some questions for using the Eclipse Java IDE.

The classes Link, LList and the interface List are in the default package:

folder

I want to use Link<E> in class LList<E>. Can I just use it like in the picture without importing the class or creating a package?

used in class

Can I also implement the interface without importing the interface or creating a package?

How is this possible?

howlger
  • 31,050
  • 11
  • 59
  • 99
  • 1
    Yes. All classes (including interfaces, & annotations) in the current folder are implicitly imported. There is no need to explicitly import them. This behaviour is an aspect of the Java language; it has nothing to do with Eclipse or any other IDE or build system. – AJNeufeld Sep 30 '17 at 04:53

1 Answers1

0

All three of them (Link, LList, List) are actually present in a package. Just this is a special case of a package, the unnamed (often called "default") package. It is not necessary to declare imports from the same package (and they fulfill this requirement).

btw. You might want to move to specific package, as using the default one is discouraged - Is the use of Java's default package a bad practice? .

Adam Kotwasinski
  • 4,377
  • 3
  • 17
  • 40