title: How to call the getters and setters of inner class attributes in the TestApplication.java class?
body: <p>I have a class AddressBook with the attributes long phoneNumber, Address tempAddress, Address permAddress where Address is the inner class of AddressBook. Its attributes are Name, City, Street, State. Both classes have getters and setters for all the attributes.</p>
  
  <p>There is another class TestApplication where I need to test the working of the application by creating AddressBook object and print permanent, temporary address and phone number in the main method.</p>
  
  <p>I could not figure out the way as to how to get to those Address class attributes into TestApplication, because of the confusing getters and setters of permAddress and tempAddress attributes.
  <a href="https://i.stack.imgur.com/RG6jG.png" rel="nofollow noreferrer">error description</a></p>
  
  <p>What should be the right approach? Not able to implement the getters and setters of attributes tempAddress and permAddress of type Address.
  So far this is the code of AddressBook.java and TestApplication.java.</p>
  
  <pre><code>    public class AddressBook{
      private long phoneNumber;
      private Address tempAddress;
      private Address permAddress;
  
      public void setPhoneNumber(long phoneNumber)
      {
          this.phoneNumber=phoneNumber;
      }
      public void setTempAddress(Address tempAddress)
      {
          this.tempAddress=tempAddress;
      }
      public void setPermAddress(Address permAddress)
      {
          this.permAddress=permAddress;
      }
  
      public long getPhoneNumber()
      {
          return phoneNumber;
      }
      public Address getTempAddress()
      {
          return tempAddress;
      }
      public Address getPermAddress()
      {
          return permAddress;
      }
  
      class Address{
          private String name;
          private String street;
          private String city;
          private String state;
  
          public void setName(String name)
          {
              this.name=name;
          }
          public void setCity(String city)
          {
              this.city=city;
          }
          public void setStreet(String street)
          {
              this.street=street;
          }
          public void setState(String state)
          {
              this.state=state;
          }
  
          public String getName()
          {
              return name;
          }
          public String getStreet()
          {
              return street;
          }
          public String getCity()
          {
              return city;
          }
          public String getState()
          {
              return state;
          }
      } 
  }
  
  
  
  import java.util.*;
  public class TestApplication {
      public static void main(String[] args) {
          Scanner sc=new Scanner(System.in);
          System.out.println("Enter the permanent address");
          System.out.println("Enter the house name");
          String hn=sc.nextLine();
          System.out.println("Enter the street");
          String stee=sc.nextLine();
          System.out.println("Enter the city");
          String city=sc.nextLine();
          System.out.println("Enter the state");
          String state=sc.nextLine();
  
          AddressBook a=new AddressBook();
          AddressBook.Address b=a.new Address();
          b.setName(hn);
          b.setStreet(stee);
          b.setCity(city);
          b.setState(state);
  
          System.out.println("Permanent address");
          AddressBook ad=new AddressBook();
          System.out.println("House name:"+ad.getPermAddress().getName());
          System.out.println("Street:"+ad.getPermAddress().getStreet());
          System.out.println("City:"+ad.getPermAddress().getCity());
          System.out.println("State:"+ad.getPermAddress().getState());
  
          System.out.println("Enter the temporary address");
          System.out.println("Enter the house name");
          String house=sc.nextLine();
          System.out.println("Enter the street");
          String street1=sc.nextLine();
          System.out.println("Enter the city");
          String city1=sc.nextLine();
          System.out.println("Enter the state");
          String state1=sc.nextLine();
          System.out.println("Enter the phone number");
          long ph=sc.nextLong();
  
  
          System.out.println("Temporary address");
          System.out.println("House name:"+ad.getTempAddress().getName());
          System.out.println("Street:"+ad.getTempAddress().getStreet());
          System.out.println("City"+ad.getTempAddress().getCity());
          System.out.println("State:"+ad.getTempAddress().getState());
  
  
          ad.setPhoneNumber(ph);
          System.out.println("Phone number"+ad.getPhoneNumber);
      }
  }
  </code></pre>