Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2016
    Rep Power

    Default Can Java have sub packages or not?

    This website suggests that Java can have sub packages:

    However a book I am reading, says that Java does not have sub packages/nested packages. As an example, the book says that
    java.nio.file.attribute.* is not a sub package of java.nio.file.* even though it appears to be. Then the author says they are different packages with names that are similar to show the relationship between their contents.

    So does Java have sub packages or not?

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Northern Virginia, United States
    Rep Power

    Default Re: Can Java have sub packages or not?

    No, at least not in terms of searching, like a directory tree. The hierarchical organization is there to sort
    of tie related packages together. But java.util.* will only include those classes in java.util, not java.util.regex
    for example. If you wanted the classes in both your would need to do

    Java Code:
    import java.util.*;
    import java.util.regex.*;
    Last edited by jim829; 06-28-2018 at 06:05 PM.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Replies: 0
    Last Post: 12-29-2012, 08:59 PM
  2. java packages and (web)applications
    By CapsLoc in forum Java Servlet
    Replies: 3
    Last Post: 11-28-2011, 01:16 PM
  3. Java Packages
    By ShitalJain in forum New To Java
    Replies: 12
    Last Post: 06-11-2011, 08:14 AM
  4. Java Packages/Jars
    By Silentstormz in forum Advanced Java
    Replies: 4
    Last Post: 09-14-2008, 07:58 PM
  5. Replies: 3
    Last Post: 02-12-2008, 11:03 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts