title: Getting person addresses from other objects using the references
body: <p>Retrieve addresses from other objects by reference.</p>
  <p>Hello, I am struggling with a particular task. Well I had two classes to do, address and person data (informations). For both classes I created constructors along with the option to display information on the screen.</p>
  <p>Address class:</p>
  <pre><code>public class adres {
  String postalCode;
  String street;
  String city;
  
  public adres(String postalCode, String street, String city){
      postalCode = postalCode;
      street = street;
      city = city;
      System.out.println(&quot;Address: \n&quot; + &quot;Postal Code: &quot; + postalCode + &quot;\nStreet: &quot; + street + &quot;\nCity: &quot; + city + &quot;\n --------------------------------- \n&quot;);
  }
  </code></pre>
  <p>}</p>
  <p>Person class:</p>
  <pre><code>public class person {
  String name;
  String surname;
  int phone_number;
  
  public person(String name, String surname, int phone_number){
      name = name;
      surname = surname;
      phone_number = phone_number;
      System.out.println(&quot;Client data:\n&quot; + &quot;name and surname: &quot; + name + &quot; &quot; + surname + &quot;\n&quot; +&quot;Phone number: &quot; + phone_number + &quot;\n&quot;);
  }
  </code></pre>
  <p>}</p>
  <p>In the main file I contained the objects, which later initialized using the constructors. The starter file code looks like this:</p>
  <pre><code>public class starter {
  public static void main(String[] args) {
  
      String name1 = &quot;John&quot;;
      String surname1 = &quot;Bush&quot;;
      int phone_number1 = 575332114;
  
      person data1 = new person(name1,surname1,phone_number1);
  
      String postalCode = &quot;47-321&quot;;
      String street = &quot;Washington St.&quot;;
      String city = &quot;Washington&quot;;
  
      adres info1 = new adres(postalCode,street,city);
  
      //-------------------------------------------------------------------
  
      String name2 = &quot;George&quot;;
      String surname2 = &quot;Denis&quot;;
      int phone_number2 = 338729416;
  
      person data2 = new person(name2,surname2,phone_number2);
  
      adres info2 = info1;
      info2 = new adres(postalCode,street,city);
  
  
      //-------------------------------------------------------------------
  
      String name3 = &quot;Tom&quot;;
      String surname3 = &quot;Rolling&quot;;
      int phone_number3 = 165776879;
  
      person data3 = new person(name3,surname3,phone_number3);
  
      String postalCode2 = &quot;17-221&quot;;
      String street2 = &quot;Green St.&quot;;
      String city2 = &quot;York&quot;;
  
      adres info3 = new adres(postalCode2,street2,city2);
  
      //-------------------------------------------------------------------
  
      String name4 = &quot;Eric&quot;;
      String surname4 = &quot;Murble&quot;;
      int phone_number4 = 335757449;
  
      person data4 = new person(name4,surname4,phone_number4);
  
      adres info4 = info3;
      info4 = new adres(postalCode2,street2,city2);
  }
  </code></pre>
  <p>}</p>
  <p>To the two Persons I've assigned previous addresses using references.  The idea was: if the address is taken from another object (and if it already exists) then assign the value from that object by reference. Did I do it correctly? The code compiles correctly, but I'm wondering how to improve it and what disadvantages the current solution has (for example, one of them is definitely the lack of conditional instructions, but I wasn't supposed to use them).</p>
  <p>Is anyone able to confirm my reasoning - and should the references look the way I presented it in the code? Thank you in advance for your help!</p>