• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Imports and nested packages

 
Ranch Hand
Posts: 53
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is a snip of code



From my understanding, this is the package structure is
aquarium.Water
aquarium.jellies.Water


If this is the case, What does the statement import aquarium.* do ?
1. Will it import both water classes ?
2. Will it throw an error because its conflicts with the structure package1.package2...packageN.Class when it finds the nested jellies package?
3. Will it simply import the Water class from the aquarium package and ignore the nested jellies package

I believe that number 3 is correct because 1 is impossible but I don't understand why 2 is not correct. For example if the class aquarium.Water didnt exist, then 2 would be correct ?
 
Sheriff
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Kevin, welcome to the Ranch!

You are correct. "import aquarium.*;" will import "aquarium.Water" only. The import wildcard syntax is not recursive, in fact you would do well to consider them completely disparate packages. The suggestion of package nesting is only really observed in the file system directory structure applied to organising the code. The notion of 'aquarium.jellies' somehow being related to 'aquarium' does not apply hold true in the code.
 
reply
    Bookmark Topic Watch Topic
  • New Topic