title: ArrayList<object> inside ArrayList<anotherObject> inside a class, to send the data in RecyclerView
body: <p>Sorry forms English in I'm French</p>
  <p>I have 3 class and 2 of them have ArrayList. Unfortunately, my object with the 2 ArrayList won't work. I use Java in Android Studio</p>
  <p>First class : Panel :</p>
  <pre><code>
  public class Panel {
      public String nameUser;
      public String street;
      public String panelId;
      public ArrayList&lt;Block&gt; listBlock;
  
      public Panel(String nameUser, String street, String panelId, ArrayList&lt;Block&gt; listBlock) {
          this.nameUser = nameUser;
          this.street = street;
          this.panelId = panelId;
          this.listBlock = listBlock;
      }
  
  
      public String getNameUser() {
          return nameUser;
      }
  
      public void setNameUser(String nameUser) {
          this.nameUser = nameUser;
      }
  
      public String getStreet() {
          return street;
      }
  
      public void setStreet(String street) {
          this.street = street;
      }
  
      public String getPanelId() {
          return panelId;
      }
  
      public void setPanelId(String panelId) {
          this.panelId = panelId;
      }
  
      public ArrayList&lt;Block&gt; getListBlock() {
          return listBlock;
      }
  
      public void setListBlock(ArrayList&lt;Block&gt; listBlock) {
          this.listBlock = listBlock;
      }
  }
  </code></pre>
  <p>Second class : Block :</p>
  <pre><code>import java.util.ArrayList;
  
  public class Block {
  
      public String nameLine;
      public ArrayList&lt;Breaker&gt; listBreaker;
  
      public String getNameLine() {
          return nameLine;
      }
  
      public void setNameLine(String nameLine) {
          this.nameLine = nameLine;
      }
  
      public ArrayList&lt;Breaker&gt; getListBreaker() {
          return listBreaker;
      }
  
      public void setListBreaker(ArrayList&lt;Breaker&gt; listBreaker) {
          this.listBreaker = listBreaker;
      }
  
      public Block(String nameLine, ArrayList&lt;Breaker&gt; listBreaker) {
          this.nameLine = nameLine;
          this.listBreaker = listBreaker;
      }
  }
  </code></pre>
  <p>Third ( Last class) : Breaker :</p>
  <pre><code>public class Breaker {
      public String name;
      public String utilisation;
  
      public Breaker(String name, String utilisation) {
          this.name = name;
          this.utilisation = utilisation;
      }
  
  
      public String getNom() {
          return name;
      }
  
      public void setNom(String nom) {
          this.name = name;
      }
  
      public String getUtilisation() {
          return utilisation;
      }
  
      public void setUtilisation(String utilisation) {
          this.utilisation = utilisation;
      }
  }
  </code></pre>
  <p>My MainActivity :</p>
  <pre><code>public class Activity_PanelHome extends AppCompatActivity {
  
      private ArrayList&lt;Panel&gt; listPanel;
      private ArrayList&lt;Block&gt; listBlock;
      private ArrayList&lt;Breaker&gt; listBreaker;
      private RecyclerView recyclerView;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_panelhome);
  
  
          recyclerView = findViewById(R.id.recyclerViewHomePage);
          ArrayList&lt;Panel&gt; listPanel = new ArrayList&lt;&gt;();
          List&lt;Block&gt; listBlock = new ArrayList&lt;&gt;();
          List&lt;Breaker&gt; listBreaker = new ArrayList&lt;Breaker&gt;();
  
          setUserInfo();
          setAdapter();
      }
      private void setAdapter() {
          RecyclerAdapter adapter = new RecyclerAdapter(listPanel);
          RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
          recyclerView.setLayoutManager(layoutManager);
          recyclerView.setItemAnimator(new DefaultItemAnimator());
          recyclerView.setAdapter(adapter);
      }
  
      private void setUserInfo() {
          listBreaker.add(new Breaker(&quot;BreakerName&quot;,&quot;BreakerUtilisation&quot;));
          listBlock.add(new Block(&quot;BlockName&quot;,listBreaker));
          listPanel.add(new Panel(&quot;PanelUserName&quot;,&quot;PanelStreet&quot;,&quot;PanelId&quot;,listBlock));
      }
  }
  </code></pre>
  <p>The error I got</p>
  <pre><code>Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.util.ArrayList.add(java.lang.Object)' on a null object reference
          at com.example.application.Activity.Activity_PanelHome.setUserInfo(Activity_PanelHome.java:48)
          at com.example.application.Activity.Activity_PanelHome.onCreate(Activity_PanelHome.java:36)
  </code></pre>
  <p>Ligne 36 : (It's the method)</p>
  <pre><code>setUserInfo();
  </code></pre>
  <p>Ligne 48 :</p>
  <pre><code>listBreaker.add(new Breaker(&quot;BreakerName&quot;,&quot;BreakerUtilisation&quot;));
  </code></pre>
  <p>Thank you in advance for your help :)</p>