Results 1 to 5 of 5
  1. #1
    allaudin's Avatar
    allaudin is offline Senior Member
    Join Date
    Apr 2013
    Posts
    271
    Rep Power
    0

    Default Default Imported Package

    Why should we need to import java.lang.Exception for Exceptions as java.lang.* is imported by default ?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default Re: Default Imported Package

    Give us an example of when you need to do this.

    Hint: packages aren't recursively imported.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,596
    Rep Power
    5

    Default Re: Default Imported Package

    Quote Originally Posted by allaudin View Post
    Why should we need to import java.lang.Exception for Exceptions as java.lang.* is imported by default ?
    For the example you provide you don't need to do it. But for something in the java.lang.reflect package you would have to, since it is not the java.lang package.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    allaudin's Avatar
    allaudin is offline Senior Member
    Join Date
    Apr 2013
    Posts
    271
    Rep Power
    0

    Default Re: Default Imported Package

    Yes, Eclipse forced me to ask this question KevinWorkman you are right ... thanks gimbal2

  5. #5
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,596
    Rep Power
    5

    Default Re: Default Imported Package

    Sure, blame the tool. That's not fair you know, Eclipse can't defend itself.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Replies: 0
    Last Post: 06-30-2013, 07:44 PM
  2. default package
    By rachushetty in forum New To Java
    Replies: 5
    Last Post: 10-31-2012, 09:38 AM
  3. Default / package-private access
    By genkuro in forum New To Java
    Replies: 1
    Last Post: 12-30-2010, 06:08 AM
  4. Default Access (package access) confusion
    By gauravrajbehl in forum New To Java
    Replies: 1
    Last Post: 11-18-2009, 10:48 AM
  5. importing from default package?
    By diggitydoggz in forum New To Java
    Replies: 6
    Last Post: 01-06-2009, 01:23 AM

Posting Permissions

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