Results 1 to 3 of 3
  1. #1
    N_i_X is offline Member
    Join Date
    Mar 2008
    Rep Power

    Question [SOLVED] Why import isnt needed whn ref is used without storing to local variable

    Hello, Guys
    This is my first thread to the Forum....

    Consider this statement

    System.getProperties().getProperty("propertyname") ;

    for this statement import of java.util.Properties is not required, but we are using method of Properties

    but it will required for this statements.
    Properties props = System.getProperties();

    Whats the reason??


  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Rep Power


    Java Code:
    System.getProperties().getProperty("propertyname") ;
    The System class does import java.util.Properties so it can handle this internally and return the String.
    If you want to declare a Properties type/object in your app then you must import java.util.Properties into your app to support the type.

  3. #3
    N_i_X is offline Member
    Join Date
    Mar 2008
    Rep Power

    Thumbs up

    Thank you,
    Ohh, i just trying to find out in JLS and other books, just didnt got it...
    Its a tricky one...

    i am feeling like a dumb right now...

    Anyways, Thanks.

Similar Threads

  1. [SOLVED] curiosity about String type variable
    By monir6464 in forum Advanced Java
    Replies: 1
    Last Post: 04-08-2008, 12:13 PM
  2. storing and retrieving a file as such
    By anil_manu in forum Advanced Java
    Replies: 0
    Last Post: 03-11-2008, 02:27 PM
  3. Storing data permanently
    By shaungoater in forum New To Java
    Replies: 2
    Last Post: 03-10-2008, 05:18 PM
  4. Replies: 0
    Last Post: 11-10-2007, 05:47 PM
  5. Storing Data
    By Khorod in forum New To Java
    Replies: 1
    Last Post: 08-03-2007, 06:48 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