title: Error: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
body: <p>I'm creating an app that display videos in a recycler view , I already can storage the videos in Database Firestore , but I'm getting this error when I run my app:</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
      at com.example.carlos.trendy.FeedRecyclerAdapter.getItemCount(FeedRecyclerAdapter.java:35)
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>public class FeedRecyclerAdapter extends RecyclerView.Adapter&lt;FeedRecyclerAdapter.ViewHolder&gt; {
  
  public List&lt;Feed&gt;feedList;
  
  public FeedRecyclerAdapter(List&lt;Feed&gt; feedList){
      this.feedList = feedList;
  }
  
  @Override
  public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  
      View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.feed_row, parent, false);
      return new ViewHolder(view);
  }
  
  @Override
  public void onBindViewHolder(ViewHolder holder, int position) {
  
      String desc_data = feedList.get(position).getDesc();
      holder.setDesc(desc_data);
  }
  
  @Override
  public int getItemCount() {
      return feedList.size();///ERROR
  }
  
  public  class ViewHolder extends RecyclerView.ViewHolder{
  
      private TextView desc;
      private View mView;
  
      public ViewHolder(View itemView) {
          super(itemView);
          mView=itemView;
      }
      public void setDesc(String descText){
          desc = mView.findViewById(R.id.post_desc);
          desc.setText(descText);
      }
  }
  }
  </code></pre>
  
  <p>FeedActivity:</p>
  
  <pre><code>public class FeedActivity extends AppCompatActivity {
  
  private Context mContext = FeedActivity.this;
  private static final int ACTIVITY_NUM = 0;
  private FirebaseFirestore firebaseFirestore;
  
  
  private RecyclerView mFeedList;
  private List&lt;Feed&gt; feedList;
  private FeedRecyclerAdapter feedRecyclerAdapter;
  
  public void videoPicker(View view){
      Intent intent = new Intent(FeedActivity.this, postActivity.class);
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
      startActivity(intent);
  
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_feed);
  
      mFeedList = this.findViewById(R.id.feed_list);
      feedRecyclerAdapter = new FeedRecyclerAdapter(feedList);
      mFeedList.setLayoutManager(new LinearLayoutManager(this));
      mFeedList.setAdapter(feedRecyclerAdapter);
  
      feedList = new ArrayList&lt;&gt;();
  
  
      firebaseFirestore = FirebaseFirestore.getInstance();
      firebaseFirestore.collection("Posts").addSnapshotListener(new EventListener&lt;QuerySnapshot&gt;() {
          @Override
          public void onEvent(QuerySnapshot documentSnapshots, FirebaseFirestoreException e) {
              for (DocumentChange documentChange: documentSnapshots.getDocumentChanges()){
                  if (documentChange.getType() == DocumentChange.Type.ADDED){
                      Feed feed = documentChange.getDocument().toObject(Feed.class);
                      feedList.add(feed);
                      feedRecyclerAdapter.notifyDataSetChanged();
                  }
              }
          }
      });
  
  
  
      setupBottomNavigationView();
  
  
  }
  
  private void setupBottomNavigationView() {
      BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavViewBar);
      BottomNavigationViewHelper.enableNavigation(mContext, bottomNavigationView);
      Menu menu = bottomNavigationView.getMenu();
      MenuItem menuItem = menu.getItem(ACTIVITY_NUM);
      menuItem.setChecked(true);
  }
  
  @Override
  protected void onStart() {
      super.onStart();
  
  
  }
  
  public static class FeedViewHolder extends RecyclerView.ViewHolder {
      View mView;
  
      public FeedViewHolder(View itemView) {
          super(itemView);
          itemView = mView;
      }
      public void setDesc(String desc){
          TextView post_desc = mView.findViewById(R.id.post_desc);
          post_desc.setText(desc);
      }
  }
  
  }
  </code></pre>
  
  <p>Can anyone help me?</p>