Thread: effeciency

    #1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    Belgium
    Posts
    39
    Rep Power
    13

    Question effeciency


    what's the most efficient?

    import java.awt.event.*;
    import javax.swing.*;
    import java.sql.*;

    OR

    import javax.swing.table.TableModel;
    import javax.swing.table.TableColumn;
    import javax.swing.table.TableColumnModel;
    import javax.swing.event.TableModelListener;

    whats the desired method to improve performance?

    or doesnt it matter? .... compiler just imports the libraries used?

    *TableModel 's a bitch *
    With Your Hand On A Hot Stove, Fifteen Seconds Can Seem Like Fifteen Minutes. Fifteen Minutes Can Seem Fifteen Seconds When You Are With A Beautiful Woman. That's The Theory Of Relativity

    -- Albert Einstein \\
  2. #2
  3. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    There is no difference in performance between using single-type-import (java.package.ClassName) vs import-on-demand (java.package.*). The compiler just uses the declarations to find the fully qualified name when resolving classes when compiling.

    However, that being said, it is generally preferred to use a list of single-type-imports for readability. It makes it very clear when maintaining code where a particular class is located.

    If you use an IDE such as Eclipse (www.eclipse.org) it will put the single-type-import names in for you.


    P.S., Just wait until you try using a JTree....
  4. #3
  5. dont click here
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    409
    Rep Power
    12
    for the most part i usually advice to go with the single style import, but when dealing with javax.swing i almost ALWAY go with javax.swing.*; simply because there are so many different classes that I use i feel its simpiler.


    i think the compiler, will compile it the same regardless, as long as it finds the classes used it will compile the same, since importing is classes that are already compiled, just access to them.
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Location
    Belgium
    Posts
    39
    Rep Power
    13
    I use single import now ... is indeed much more readable....
    With Your Hand On A Hot Stove, Fifteen Seconds Can Seem Like Fifteen Minutes. Fifteen Minutes Can Seem Fifteen Seconds When You Are With A Beautiful Woman. That's The Theory Of Relativity

    -- Albert Einstein \\

IMN logo majestic logo threadwatch logo seochat tools logo