java.lang.NullPointerException error with adapter how to fix it? : <p>I'm getting a fatal exception / null pointer exception 
i dont know what is the problem and why this error is happen </p>

<p>If any additional information is required please let me know.</p>

<p>LOGCAT</p>

<pre><code>&gt; 03-09 18:18:52.423 3765-3765/com.mosabalzouby.myapplication
&gt; E/AndroidRuntime: FATAL EXCEPTION: main
&gt;                                                                               java.lang.NullPointerException
&gt;                                                                                   at
&gt; com.mosabalzouby.myapplication.IndianMoviesAdapter.onBindViewHolder(IndianMoviesAdapter.java:38)
&gt;                                                                                   at
&gt; com.mosabalzouby.myapplication.IndianMoviesAdapter.onBindViewHolder(IndianMoviesAdapter.java:16)
&gt;                                                                                   at
&gt; android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:5217)
&gt;                                                                                   at
&gt; android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5250)
&gt;                                                                                   at
&gt; android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4487)
&gt;                                                                                   at
&gt; android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4363)
&gt;                                                                                   at
&gt; android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1961)
&gt;                                                                                   at
&gt; android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1370)
&gt;                                                                                   at
&gt; android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1333)
&gt;                                                                                   at
&gt; android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:562)
&gt;                                                                                   at
&gt; android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2900)
&gt;                                                                                   at
&gt; android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3071)
&gt;                                                                                   at android.view.View.layout(View.java:11180)
&gt;                                                                                   at android.view.ViewGroup.layout(ViewGroup.java:4203)
&gt;                                                                                   at android.widget.RelativeLayout.onLayout(RelativeLayout.java:925)
&gt;                                                                                   at android.view.View.layout(View.java:11180)
&gt;                                                                                   at android.view.ViewGroup.layout(ViewGroup.java:4203)
&gt;                                                                                   at
&gt; android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1037)
&gt;                                                                                   at
&gt; android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:747)
&gt;                                                                                   at
&gt; android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
&gt;                                                                                   at
&gt; android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1156)
&gt;                                                                                   at
&gt; android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:760)
&gt;                                                                                   at android.view.View.layout(View.java:11180)
&gt;                                                                                   at android.view.ViewGroup.layout(ViewGroup.java:4203)
&gt;                                                                                   at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
&gt;                                                                                   at android.view.View.layout(View.java:11180)
&gt;                                                                                   at android.view.ViewGroup.layout(ViewGroup.java:4203)
&gt;                                                                                   at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628)
&gt;                                                                                   at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486)
&gt;                                                                                   at android.widget.LinearLayout.onLayout(LinearLayout.java:1399)
&gt;                                                                                   at android.view.View.layout(View.java:11180)
&gt;                                                                                   at android.view.ViewGroup.layout(ViewGroup.java:4203)
&gt;                                                                                   at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
&gt;                                                                                   at android.view.View.layout(View.java:11180)
&gt;                                                                                   at android.view.ViewGroup.layout(ViewGroup.java:4203)
&gt;                                                                                   at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628)
&gt;                                                                                   at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486)
&gt;                                                                                   at android.widget.LinearLayout.onLayout(LinearLayout.java:1399)
&gt;                                                                                   at android.view.View.layout(View.java:11180)
&gt;                                                                                   at android.view.ViewGroup.layout(ViewGroup.java:4203)
&gt;                                                                                   at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
&gt;                                                                                   at android.view.View.layout(View.java:11180)
&gt;                                                                                   at android.view.ViewGroup.layout(ViewGroup.java:4203)
&gt;                                                                                   at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1468)
&gt;                                                                                   at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2418)
&gt;                                                                                   at android.os.Handler.dispatchMessage(Handler.java:99)
&gt;                                                                                   at android.os.Looper.loop(Looper.java:137)
&gt;                                                                                   at android.app.ActivityThread.main(ActivityThread.java:4340)
&gt;                                                                                   at java.lang.reflect.Method.invokeNative(Native Method)
&gt;                                                                                   at java.lang.reflect.Method.invoke(Method.java:511)
&gt;                                                                                   at
&gt; com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
&gt;                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
&gt;                                                                                   at dalvik.system.NativeStart.main(Native Method)
</code></pre>

<p>MainActivity :</p>

<pre><code>  List&lt;IndianMovies&gt; movies=new ArrayList&lt;&gt;();

        int posters[]={R.mipmap.avengers,R.mipmap.avengers,R.mipmap.avengers,R.mipmap.avengers,R.mipmap.avengers,R.mipmap.avengers};
        String moviename[]={"aaaaa","bbbbbb","ccccc","vvvvvv","eeeeeee","wwwwww"};
        String movierate[]={"9.9","5.5","2.3","4.4","5.1","6.2"};
        String moviestory[]={"aaaaaaaaaaa","aaaaaaaaa","wwwwwwwwwww","eeeee","rrrrrrr","qqqqq"};


        for (int i=0;i&lt;posters.length;i++){
            IndianMovies movie=
                    new IndianMovies(moviename[i],movierate[i],moviestory[i],posters[i]);
            movies.add(movie);


        }

        RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        IndianMoviesAdapter adapter = new IndianMoviesAdapter(movies);
        recyclerView.setAdapter(adapter);
</code></pre>

<p>My Adapter :</p>

<pre><code>public class IndianMoviesAdapter extends RecyclerView.Adapter&lt;IndianMoviesAdapter.IndianMovieHolder&gt;{

    List&lt;IndianMovies&gt; moviesList;
    public IndianMoviesAdapter(List&lt;IndianMovies&gt; moviesList){
        this.moviesList=moviesList;


    }


    @Override
    public IndianMovieHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View row = LayoutInflater.from(parent.getContext()).inflate(R.layout.indian_movie_row,parent,false);
        IndianMovieHolder holder = new IndianMovieHolder(row);

        return holder;
    }

    @Override
    public void onBindViewHolder(IndianMovieHolder holder, int position) {
    IndianMovies movie =moviesList.get(position);
        holder.movietitle.setText(movie.moviename);
        holder.movierat.setText(movie.movierate);
        holder.moviesdesc.setText(movie.moviestory);
        holder.poster.setImageResource(movie.posterimage);
    }

    @Override
    public int getItemCount() {
        return moviesList.size();
    }

    class IndianMovieHolder extends RecyclerView.ViewHolder{
        TextView movietitle,movierat,moviesdesc;
        ImageView poster;


        public IndianMovieHolder(View itemView) {
            super(itemView);


            movietitle =(TextView) itemView.findViewById(R.id.movietitleTV);
            movietitle =(TextView) itemView.findViewById(R.id.movieratTV);
            moviesdesc =(TextView) itemView.findViewById(R.id.moviedescTV);
            poster =(ImageView) itemView.findViewById(R.id.movieposteIMG);


        }
    }

}
</code></pre>

<p>How to fix it ??</p>
