title: Accessing child property inside an array list of base class
body: <p>I am trying to access the property of the child class inside an array list of the base class</p>
  
  <pre><code>ArrayList&lt;Parent&gt; listValue = new ArrayList&lt;Parent&gt;();
  listValue.add(new Child1());
  listValue.add(new Child2());
  </code></pre>
  
  <p>This is the class parent</p>
  
  <pre><code>class Parent{
  String name;
  public Parent(String name){
    this.name = name
    }
  }
  </code></pre>
  
  <p>This is the child class </p>
  
  <pre><code>class Child extends Parent{
  String childOnly;
  
  public Child(String name){
  super(name);
   }
  }
  </code></pre>
  
  <p>And i am trying to access the class property somehow like this</p>
  
  <pre><code>string value = listValue.get(1).childOnly       
  </code></pre>