×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Super Contributor
    Join Date
    Jan 2008
    Location
    Amravati, India
    Posts
    546

    import * or import specific

    What is the difference between jar file generated in these 2 case:

    Case 1:
    Code:
    import javax.microedition.lcdui.Canvas;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Graphics;
    Case 2:
    Code:
    import javax.microedition.lcdui.*;
    I know case 2 will bring lots & lots of identifier which may result in identifier name collision.
    But I am talking about the generated jar file.
    Which one will you recommend? Why?

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: import * or import specific

    So far as code is concerned, it make no difference whatsoever. The JAR will be identical either way.

    "import" directives are a kind of look-up path for the compiler. When you use a class name (without package name), the compiler uses the imports (plus the implied import of java.lang.*) to find a match. It must find exactly one match, no more, no less.

    As you say, importing "*" increases the chance of importing two classes with the same simple-name. Name conflicts mean you have to use the classes fully qualified name (FQN), which can make the code less readable.

    In J2ME, this is less of an issue, because the API is small, and applications are usually small (compared to J2SE or J2EE).

    A decent IDE (like eclipse) will automatically add single-class imports for you.

  3. #3
    Super Contributor
    Join Date
    Jan 2008
    Location
    Amravati, India
    Posts
    546

    Re: import * or import specific

    Thanks.

    This line is to suppress message "The message you have entered is too short. Please lengthen your message to at least 10 characters."

Similar Threads

  1. GoogleIt
    By deepika.mangla in forum Symbian
    Replies: 5
    Last Post: 2011-05-28, 11:04
  2. isNotVNC (but I need help!)
    By rotra in forum Symbian
    Replies: 5
    Last Post: 2008-11-02, 10:15
  3. bluetooth setting using bluecove
    By amoon108 in forum Bluetooth Technology
    Replies: 0
    Last Post: 2008-10-15, 10:11
  4. problem on running my application
    By rsf in forum Symbian
    Replies: 7
    Last Post: 2007-10-21, 15:56
  5. SocketConnection Work on 6600&Emulators BUT NOT IN 6680
    By eerant in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2006-03-11, 00:35

Posting Permissions

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