Results 1 to 4 of 4

Thread: import packages

  1. #1
    gregorio99 is offline Member
    Join Date
    Nov 2009
    Posts
    1
    Rep Power
    0

    Default import packages

    Hi!
    In my program, the two first line are:
    import java.awt.*;
    import java.awt.event.*;
    My question is why I must write it like this?
    If import java.awt.* - let me get everything from awt so In my opinion I don't need line java.awt.event.*

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    The wild card, * sign, only allow to import/use the classes in this package visible, not any of the sub-packages.

  3. #3
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    java.awt.* only imports classes from the java.awt package and not classes from packages under it.

  4. #4
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    843
    Rep Power
    6

    Default

    Hi,
    event is a subpackage here.nothing but subfolder...

    awt is a parent package nothing but main folder here...
    Ramya:cool:

Similar Threads

  1. Replies: 3
    Last Post: 02-12-2008, 12:03 PM
  2. Using packages
    By prfalco in forum New To Java
    Replies: 5
    Last Post: 01-31-2008, 11:38 PM
  3. packages
    By ai_2007 in forum Advanced Java
    Replies: 1
    Last Post: 07-31-2007, 01:10 PM
  4. Problems with packages (import statements)
    By ai_2007 in forum Advanced Java
    Replies: 1
    Last Post: 06-29-2007, 12:57 PM

Posting Permissions

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