Import declaration

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rpm27
    New Member
    • Jan 2008
    • 23

    #1

    Import declaration

    Hey, I have a small style question. Which import style is preferable (or better) to use. A single one like
    Code:
    import java.util.System;
    or an import-on-demand like
    Code:
    import java.util.*;
    ? Is there any advantage or disadvantage for each declaration? Thank you.
  • sukatoa
    Contributor
    • Nov 2007
    • 539

    #2
    Originally posted by rpm27
    Hey, I have a small style question. Which import style is preferable (or better) to use. A single one like
    Code:
    import java.util.System;
    or an import-on-demand like
    Code:
    import java.util.*;
    ? Is there any advantage or disadvantage for each declaration? Thank you.
    They are the same... the JVM have it's built in code optimizer.... it removes unnecessary codes/excess codes....

    But for me, it is nice to show the specific import.... so that, when i have a problem/ forgot how to implement like this, i can scan easily my previous programs/codes for review.....

    for example, i forgot on how to use FileNameExtensi onFilter...
    so i could just view my previous codes who has an import with the FileNameExtensi onFilter....

    i have subreasons.... yet nonsense... :)

    So, depends on you....


    sukatoa

    Comment

    • rpm27
      New Member
      • Jan 2008
      • 23

      #3
      Yes, right after writing this post, I convinced myself that import individual classes would help me as I'm a Java beginner. Thanks anyway. :-)

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by rpm27
        Yes, right after writing this post, I convinced myself that import individual classes would help me as I'm a Java beginner. Thanks anyway. :-)
        You could even write code without using the import statement as well.
        The import statement just saves you a lot of typing.

        Comment

        Working...