Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Try this one:</strong> </p> <pre><code> Person person = new Person(); Dog dog1 = new Dog(); dog1.setAge(12); Dog dog2 = new Dog(); dog2.setAge(34); person.addDog(dog1); //dog 1 person.addDog(dog2); //dog 2 person.listDogs(); //list of all dogs </code></pre> <p><strong>//PERSON</strong></p> <pre><code>public class Person { // instance variables - replace the example below with your own private String name; private int age; private String address; private ArrayList&lt;Dog&gt; dogs = new ArrayList&lt;Dog&gt;(); /** * Constructor for objects of class Person */ public Person() { this.name = name; this.age = age; this.address = address; } public void addDog(Dog dog) { this.dogs.add(dog); } public void listDogs() { for(Dog item : this.dogs) { System.out.println(item.getAge()); } } //Set Methods: public void setName () { this.name = name; } public void setAge () { this.age = age; } public void setAddress () { this.address = address; } //Get Methods: public String getName () { return name; } public int getAge () { return age; } public String getAddress () { return address; } } </code></pre> <p><strong>//DOG</strong></p> <pre><code>public class Dog { // instance variables - replace the example below with your own private String name; private int age; public Dog() { this.name = name; this.age = age; } //Set Methods: public void setName () { this.name = name; } public void setAge (int age) { this.age = age; } //Get Methods: public String getName () { return name; } public int getAge () { return age; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload