Reputation: 437
I created a groovy class with a method that returns Collection<String>
. It works, but it's weird that there is no Collection
in the import statements.
The class inherits a super class. That super class (java) does have the import statement for collection: import java.util.Collection;
Is it the expected behavior?
Does java or groovy inherit imports too? I doubt that.
Upvotes: 6
Views: 1588
Reputation: 72844
No imports are not inherited between classes.
In Groovy
all of the below packages are imported by default.
Collection
)Upvotes: 8
Reputation: 84756
Have a look at default imports. This is expected behavior. There's no import inheritance. All these packages are imported for every class.
Upvotes: 3