title: Attempt to invoke virtual method 'boolean java.util.ArrayList.add on a null object reference
body: <p>I'm creating an Android application. The problem is that when I press the button and pass the data to the new array, it goes to black and giving me this error:</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
  </code></pre>
  
  <p>By debugging, it gives me something in the string:</p>
  
  <pre><code>mExampleList.add(Ticket)
  </code></pre>
  
  <p>My ExampleAdapter class:</p>
  
  <pre><code>public class ExampleAdapter extends RecyclerView.Adapter&lt;ExampleAdapter.ExampleViewHolder&gt;{
  
      private ArrayList&lt;ExampleItemRecyclerview&gt;mExampleList;
  
      public class ExampleViewHolder extends RecyclerView.ViewHolder{
  
           public TextView mTextticket;
           public TextView mTextredattore;
           public TextView mTexttarga;
           public TextView mTextdataA;
           public TextView mTextmanutenzioneG;
           public TextView mTextdataC;
  
           public ExampleViewHolder(View itemView) {
              super(itemView);
              mTextticket = itemView.findViewById(R.id.txt_ticket);
              mTextredattore = itemView.findViewById(R.id.txt_redattore);
              mTexttarga = itemView.findViewById(R.id.txt_targa);
              mTextdataA = itemView.findViewById(R.id.txt_dataA);
              mTextmanutenzioneG = itemView.findViewById(R.id.txt_materiale);
              mTextdataC = itemView.findViewById(R.id.txt_dataC);
  
          }
      }
  
      public ExampleAdapter(ArrayList&lt;ExampleItemRecyclerview&gt;examplelist){
          mExampleList = examplelist;
          //todo creazione di una nuova ArrayList Item
          //mExampleListFull = new ArrayList&lt;&gt;(examplelist);
  
      }
  
      @Override
      public ExampleViewHolder onCreateViewHolder( ViewGroup parent , int view) {
          //todo creazione variabile View
          View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.example_item_recyclerview,parent,false);
          ExampleViewHolder evh = new ExampleViewHolder(v);
          return evh;
      }
  
      @Override
      public void onBindViewHolder(ExampleViewHolder holder, int position) {
  
          ExampleItemRecyclerview currentItem = mExampleList.get(position);
  
          holder.mTextticket.setText(Integer.toString(currentItem.getTicket()));
          holder.mTextredattore.setText(currentItem.getRedattore());
          holder.mTexttarga.setText(currentItem.getTarga());
          holder.mTextdataA.setText(Integer.toString(currentItem.getDataApertura()));
          holder.mTextmanutenzioneG.setText(currentItem.getMaterialeGuasto());
          holder.mTextdataC.setText(Integer.toString(currentItem.getDataChiusura()));
  
      }
  
      @Override
      public int getItemCount() {
  
           return mExampleList.size();
      }
  
  }
  </code></pre>
  
  <p>My Visualizza class:</p>
  
  <pre><code>public class Visualizza extends AppCompatActivity {
  
      ArrayList&lt;ExampleItemRecyclerview&gt; mExampleList;
  
      RecyclerView mRecyclearView;
      RecyclerView.Adapter mAdapter;
      RecyclerView.LayoutManager mLayoutManager;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.recyclerview);
  
          ArrayList&lt;ExampleItemRecyclerview&gt;examplelist = new ArrayList&lt;&gt;();
          //examplelist = new ArrayList&lt;&gt;();
          examplelist.add(new ExampleItemRecyclerview(123356,"ALESSANDRO","EP562WS",12052018,"Lampeggiante Guasto",23102018));
          examplelist.add(new ExampleItemRecyclerview(34567,"FRANCESCO", "EP762NS",19052019,"Motore Guasto",21052019));
          examplelist.add(new ExampleItemRecyclerview(34353,"ALESSANDRO","EP760WR",25052017,"Freni Guasti",10122018));
  
  
          mRecyclearView  = findViewById(R.id.miorecyclerView);
          mRecyclearView.setHasFixedSize(true);
          mLayoutManager = new LinearLayoutManager(this);
          //mAdapter = new ExampleAdapter(mExampleList);
          mAdapter = new ExampleAdapter(examplelist);
          mRecyclearView.setLayoutManager(mLayoutManager);
          mRecyclearView.setAdapter(mAdapter);
  
          Bundle incomingMessages = getIntent().getExtras();
          if(incomingMessages != null){
              int  ticket = Integer.parseInt(incomingMessages.getString("ticket"));
  
              String redattore = incomingMessages.getString("redattore");
              String targa = incomingMessages.getString("targa");
              int dataA = Integer.parseInt(incomingMessages.getString("dataA"));
              String materiale = incomingMessages.getString("materiale");
              int dataC = Integer.parseInt(incomingMessages.getString("dataC"));
  
              //TODO creazione nuova scheda Ticket
              ExampleItemRecyclerview Ticket = new ExampleItemRecyclerview(ticket,redattore,targa,dataA,materiale,dataC);
              mExampleList.add(Ticket);
              mAdapter.notifyDataSetChanged();
  
          } 
      }
  }
  </code></pre>