Results 1 to 4 of 4
  1. #1
    mrbharatmehta is offline Member
    Join Date
    Mar 2009
    Posts
    13
    Rep Power
    0

    Default Static Imports in Java 5

    Hi Folks,

    J2SE 1.5 introduced the concept of static imports. Can we discuss as to what benefits will that give to a Java Developer?

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Convenience. So that you don't have to type the class name in order to use the static field. Earlier this was done by declaring them in an interface then having the class implement that interface, which is not, exactly, the purpose of interfaces and can lead to other problems. That's all.

  3. #3
    mrbharatmehta is offline Member
    Join Date
    Mar 2009
    Posts
    13
    Rep Power
    0

    Default

    Thanks masijade. so what is we try to import static methods that have the same signature or static fields that have the same name from two or more classes.

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    You can't. That didn't work properly in the "interface" variety either. One, or the other, or both, will have to be done without the static import.

Similar Threads

  1. Imports
    By whosadork in forum New To Java
    Replies: 5
    Last Post: 09-07-2008, 02:32 AM
  2. How to use Static Imports
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 08:37 PM
  3. Static imports (Java 5 and above)
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-17-2007, 11:02 AM
  4. Replies: 1
    Last Post: 08-07-2007, 06:05 AM
  5. Replies: 1
    Last Post: 08-01-2007, 10:25 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
  •