Results 1 to 2 of 2
  1. #1
    bugger is offline Senior Member
    Join Date
    Nov 2007
    Posts
    111
    Rep Power
    0

    Default retrieving Properties

    Java Code:
    		Properties defaults = new Properties();
    		defaults.put("color", "black");
    
    		Properties props = new Properties(defaults);
    
    		System.out.println(props.get("color"));
    The following code gives null as output. I am setting the property named color but I am not able to retrieve it. Where is the problem?

  2. #2
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    9

    Default

    I'm assuming when you create a new Properties object that there are two methods put and get, as well as a constructor that takes a Properties object. When you call put, it takes two arguments - of type String. And when you go to retrieve the value of one of the instance variables using get you're passing a String again. The questions become, what are the types of your instance variables, what are their values after you use put and what is the correct function of get?
    Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
    Want to voice your opinion on your IDE/Editor of choice? Vote now!
    Got a little Capt'n in you? (drink responsibly)

Similar Threads

  1. JDO - Retrieving a persisted object
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-17-2008, 08:46 AM
  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. Retrieving out objects from Vector
    By tuckker in forum New To Java
    Replies: 3
    Last Post: 12-03-2007, 06:52 AM
  4. Retrieving data from the DB
    By yuchuang in forum JDBC
    Replies: 2
    Last Post: 11-27-2007, 09:59 AM
  5. Problem with storing and retrieving from a textfile
    By Albert in forum Advanced Java
    Replies: 1
    Last Post: 07-13-2007, 04:01 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
  •