Can't figure out which variable is null in NullPointerException
<p>I'm very new at Android/Java development, although I'm an experienced web dev. I've read <a href="https://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how-do-i-fix-it">this</a> and <a href="https://stackoverflow.com/questions/3988788/what-is-a-stack-trace-and-how-can-i-use-it-to-debug-my-application-errors">this</a>, and am still having problems.</p>

<p>I have a SQLite database with a table called Restaurants, that stores, well, restaurants. I'm trying to use a RecyclerView to display a list of restaurants.</p>

<p>I'm getting a null pointer exception, and can't seem to figure out what is null.</p>

<p>Here's my <code>RecyclerView</code> class:</p>

<pre><code>package com.myapp.lunchboxchicago.adapters;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.myapp.lunchboxchicago.Message;
import com.myapp.lunchboxchicago.R;
import com.myapp.lunchboxchicago.restaurants.Restaurant;

/**
 * Created by estrom on 3/23/2016.
 */
public class RestaurantViewAdapter extends RecyclerView.Adapter&lt;RestaurantViewAdapter.RestaurantViewHolder&gt; {
    public static final String TAG = RestaurantViewAdapter.class.getSimpleName();
    private Restaurant[] mRestaurants;
    private Context mContext;

    public RestaurantViewAdapter(Context context, Restaurant[] restaurants) {
        mContext = context;
        mRestaurants = restaurants;
    }

    @Override
    public RestaurantViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.restaurant_list_item, parent, false);
        RestaurantViewHolder viewHolder = new RestaurantViewHolder(view);

        return viewHolder;
    }

    @Override
    public void onBindViewHolder(RestaurantViewHolder holder, int position) {
        holder.bindRestaurant(mRestaurants[position]);
    }

    @Override
    public int getItemCount() {
        return mRestaurants.length;
    }

    public class RestaurantViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
        public TextView mRestaurantName;

        public RestaurantViewHolder(View itemView) {
            super(itemView);
            mRestaurantName = (TextView) itemView.findViewById(R.id.restaurantNameLabel);
            itemView.setOnClickListener(this);
        }

        public void bindRestaurant(Restaurant restaurant) {
            Log.wtf(TAG, "Binding " + restaurant.getName());
            Log.wtf(TAG, "To TextView ID: " + mRestaurantName.getId());
            mRestaurantName.setText(restaurant.getName());
        }

        @Override
        public void onClick(View v) {
            Message.message(mContext, "We'd open " + mRestaurantName + " in the view screen");
        }
    }
}
</code></pre>

<p>The two <code>Log</code> statements in <code>bindRestaurant</code> return the following:</p>

<pre><code>03-26 19:17:34.033 30414-30414/com.myapp.lunchboxchicago E/RestaurantViewAdapter: Binding Shamrock Club
03-26 19:17:34.050 30414-30414/com.myapp.lunchboxchicago E/RestaurantViewAdapter: To TextView ID: 2131558502
</code></pre>

<p>So it looks like both objects required exist and are instantiated. But I'm still getting this error on the very next line (<code>mRestaurantName.setText(restaurant.getName());</code>)</p>

<pre><code>03-26 19:17:34.057 30414-30414/com.myapp.lunchboxchicago D/AndroidRuntime: Shutting down VM
03-26 19:17:34.058 30414-30414/com.myapp.lunchboxchicago E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                  Process: com.myapp.lunchboxchicago, PID: 30414
                                                                                  java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.myapp.lunchboxchicago.restaurants.Restaurant.getName()' on a null object reference
                                                                                      at com.myapp.lunchboxchicago.adapters.RestaurantViewAdapter$RestaurantViewHolder.bindRestaurant(RestaurantViewAdapter.java:62)
                                                                                      at com.myapp.lunchboxchicago.adapters.RestaurantViewAdapter.onBindViewHolder(RestaurantViewAdapter.java:44)
                                                                                      at com.myapp.lunchboxchicago.adapters.RestaurantViewAdapter.onBindViewHolder(RestaurantViewAdapter.java:18)
</code></pre>

<p>I'm confused. What object am I missing that is null here?</p>