title: accessing an object array item, java
body: <p>I have created a number objects using an array statement, and I can println the values passed within the class as it is created, but when I try and retrieve element values from outside of the class (monopolygame class) it doesn't recognise the refrence - how can I refrence this correctly?</p>
  
  <pre><code>public class monopolygame {
  
      public static void main(String[] args) {
  
          //set up array of 18 objects    
          property properties[] = new property[18];
  
          //create 18 property objects and populate array
          properties[0] = new property("a","available",400,500);//create property
          properties[1] = new property("b","available",400,500);//create property 
          properties[2] = new property("c","available",200,300);//create property 
          properties[3] = new property("d","available",100,180);//create property
          properties[4] = new property("e","available",400,700);//create property
      }
  }
  </code></pre>
  
  <p>property class...</p>
  
  <pre><code>public class property
  {
     public static void main(String[] args)
     {
     }
  
     //constructor
     public property(String propertyname, String owner, double price, double rent) 
     {
          System.out.println("Property info for " + propertyname 
                             + " - Rent : £" + rent 
                             + "Price : £" + price 
                             + "owned by :" + owner);
      }   
  }
  </code></pre>
  
  <p>I am using this kind of reference in the monopoly class to try and access the data</p>
  
  <pre><code>if (properties[2].propertyname == "available")
  {
      System.out.println("avaialble");
  }
  else
  {
      System.out.println("sold");
  }
  </code></pre>
  
  <p>Thanks</p>