title: Is it bad practice to add an Object to a static ArrayList in constructor?
body: <p>As the title shows, I was wondering if the below code is bad practice? I have read that this approach could be bad because of garbage collection issues, however other posts have said that this is an acceptable way of storing Objects. </p>
  
  <p>Is it better to make a new class purely to deal with the list of Companies? </p>
  
  <p>Thank you.    </p>
  
  <pre><code>public class Company{
      private static ArrayList&lt;Company&gt; allCompanies = new ArrayList&lt;&gt;(); 
      String name;
      String email;
      String phoneNumber;
      String postalAddress;
  
      public Company(String name, String email, String phoneNumber, String postalAddress){
          this.name = name;
          this.email = email;
          this.phoneNumber = phoneNumber;
          this.postalAddress = postalAddress;
          allCompanies.add(this);
  
      }
  
      public static ArrayList&lt;Company&gt; getAllCompanies() {
          return allCompanies;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public String getPhoneNumber() {
          return phoneNumber;
      }
  
      public void setPhoneNumber(String phoneNumber) {
          this.phoneNumber = phoneNumber;
      }
  
      public String getPostalAddress() {
          return postalAddress;
      }
  
      public void setPostalAddress(String postalAddress) {
          this.postalAddress = postalAddress;
      }
  
  
  
  }
  </code></pre>