title: Attempt to invoke virtual method 'int.java.lang.Integer.intValue()' on a null object reference at Cast.writetoParcel
body: <p><a href="https://i.stack.imgur.com/kZYoc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kZYoc.png" alt="Error Image"></a></p>
  
  <blockquote>
    <p>Getting Error 
    FATAL EXCEPTION: main
                                                                               Process: com.example.wuntu.tv_bucket, PID: 3895
                                                                               java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
                                                                                   at com.example.wuntu.tv_bucket.Models.Cast.writeToParcel(Cast.java:136)
                                                                                   at android.os.Parcel.writeParcelable(Parcel.java:1437)
                                                                                   at android.os.Parcel.writeValue(Parcel.java:1343)
                                                                                   at android.os.Parcel.writeList(Parcel.java:759)
                                                                                   at android.os.Parcel.writeValue(Parcel.java:1365)
                                                                                   at android.os.Parcel.writeArrayMapInternal(Parcel.java:686)
                                                                                   at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330)
                                                                                   at android.os.Bundle.writeToParcel(Bundle.java:1079)
                                                                                   at android.os.Parcel.writeBundle(Parcel.java:711)
                                                                                   at android.content.Intent.writeToParcel(Intent.java:8790)
                                                                                   at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:3112)
                                                                                   at android.app.Instrumentation.execStartActivity(Instrumentation.java:1541)
                                                                                   at android.app.Activity.startActivityForResult(Activity.java:4284)
                                                                                   at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50)
                                                                                   at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:79)
                                                                                   at android.app.Activity.startActivityForResult(Activity.java:4231)
                                                                                   at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:859)
                                                                                   at android.app.Activity.startActivity(Activity.java:4568)
                                                                                   at android.app.Activity.startActivity(Activity.java:4536)
                                                                                   at com.example.wuntu.tv_bucket.Adapters.CastDetailAdapter$1.onClick(CastDetailAdapter.java:124)
                                                                                   at android.view.View.performClick(View.java:5698)
                                                                                   at android.widget.TextView.performClick(TextView.java:10908)
                                                                                   at android.view.View$PerformClick.run(View.java:22557)
                                                                                   at android.os.Handler.handleCallback(Handler.java:739)
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                   at android.os.Looper.loop(Looper.java:158)
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:7231)
                                                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)</p>
  </blockquote>
  
  <p>Getting error in sending <code>arraylist</code> of object from adapter to other activity. I wanna send my <code>arraylist</code> from <code>onBindViewHolder</code> method of Adapter to another activity but its is showing null exception error on the Cast Class in <code>writetoParcel</code> Method. How to send <code>arraylist</code> properly?</p>
  
  <p>Cast Class </p>
  
  <pre><code>public class Cast implements Parcelable {
  
      @SerializedName("cast_id")
      @Expose
      private Integer castId;
      @SerializedName("character")
      @Expose
      private String character;
      @SerializedName("credit_id")
      @Expose
      private String creditId;
      @SerializedName("gender")
      @Expose
      private Integer gender;
      @SerializedName("id")
      @Expose
      private Integer id;
      @SerializedName("name")
      @Expose
      private String name;
      @SerializedName("order")
      @Expose
      private Integer order;
      @SerializedName("profile_path")
      @Expose
      private String profilePath;
  
      public Cast(){
  
      }
  
      protected Cast(Parcel in) {
          character = in.readString();
          id = in.readInt();
          name = in.readString();
          profilePath = in.readString();
      }
  
      public static final Creator&lt;Cast&gt; CREATOR = new Creator&lt;Cast&gt;() {
          @Override
          public Cast createFromParcel(Parcel in) {
              return new Cast(in);
          }
  
          @Override
          public Cast[] newArray(int size) {
              return new Cast[size];
          }
      };
  
      public Integer getCastId() {
          return castId;
      }
  
      public void setCastId(Integer castId) {
          this.castId = castId;
      }
  
      public String getCharacter() {
          return character;
      }
  
      public void setCharacter(String character) {
          this.character = character;
      }
  
      public String getCreditId() {
          return creditId;
      }
  
      public void setCreditId(String creditId) {
          this.creditId = creditId;
      }
  
      public Integer getGender() {
          return gender;
      }
  
      public void setGender(Integer gender) {
          this.gender = gender;
      }
  
      public Integer getId() {
          return id;
      }
  
      public void setId(Integer id) {
          this.id = id;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public Integer getOrder() {
          return order;
      }
  
      public void setOrder(Integer order) {
          this.order = order;
      }
  
      public String getProfilePath() {
          return profilePath;
      }
  
      public void setProfilePath(String profilePath) {
          this.profilePath = profilePath;
      }
  
      @Override
      public int describeContents() {
          return 0;
      }
  
      @Override
      public void writeToParcel(Parcel parcel, int i)
      {
          parcel.writeString(name);
          parcel.writeString(profilePath);
          parcel.writeString(character);
          parcel.writeInt(id);
      }
  }
  </code></pre>
  
  <p>CastDetailAdapter Class</p>
  
  <pre><code>public class CastDetailAdapter extends RecyclerView.Adapter&lt;RecyclerView.ViewHolder&gt; {
  
      private ArrayList&lt;Cast&gt; detailArrayList = new ArrayList&lt;&gt;() ;
      private UrlConstants urlConstants = UrlConstants.getSingletonRef();
      private Cast cast;
      private final int VIEW_ITEM = 0;
      private final int VIEW_PROG = 1;
      private Context context;
      MovieView a;
      ArrayList&lt;Cast&gt; FullArrayList = new ArrayList&lt;&gt;();
  
      public CastDetailAdapter(MovieView movieView, ArrayList&lt;Cast&gt; detailArrayList,ArrayList&lt;Cast&gt; subCastArrayList)
      {
          a = movieView;
          this.detailArrayList = subCastArrayList;
          this.FullArrayList = detailArrayList;
      }
  
  
      public class MyViewHolder1 extends RecyclerView.ViewHolder
      {
          ImageView cast_profile_picture;
          TextView cast_name,cast_character_name;
  
          public MyViewHolder1(View view)
          {
              super(view);
              cast_profile_picture = (ImageView) view.findViewById(R.id.thumbnail);
              cast_name = (TextView) view.findViewById(R.id.title);
              cast_character_name = (TextView) view.findViewById(R.id.count);
          }
      }
  
      public class FooterViewHolder1 extends RecyclerView.ViewHolder
      {
          TextView view_more;
  
          public FooterViewHolder1(View itemView) {
              super(itemView);
              view_more = (TextView) itemView.findViewById(R.id.view_more);
  
  
          }
      }
  
      @Override
      public int getItemViewType(int position) {
          if (isPositionItem(position))
              return VIEW_ITEM;
          return VIEW_PROG;
      }
  
      private boolean isPositionItem(int position) {
          return position != getItemCount() -1;
      }
      @Override
      public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
      {
          context = parent.getContext();
  
          if (viewType == VIEW_ITEM)
          {
              View v =  LayoutInflater.from(parent.getContext())
                      .inflate(R.layout.cast_details, parent, false);
              return new MyViewHolder1(v);
  
          } else if (viewType == VIEW_PROG){
              View v = LayoutInflater.from(parent.getContext())
                      .inflate(R.layout.footer_layout_movie_details, parent, false);
              return new FooterViewHolder1(v);
          }
          return null;
  
      }
  
      @Override
      public void onBindViewHolder(RecyclerView.ViewHolder holder, int position)
      {
          if(holder instanceof MyViewHolder1)
          {
              cast = detailArrayList.get(position);
              ((MyViewHolder1)holder).cast_character_name.setText(cast.getCharacter());
              ((MyViewHolder1)holder).cast_name.setText(cast.getName());
              String url3 = urlConstants.URL_Image + cast.getProfilePath();
              Picasso.with(context)
                      .load(url3)
                      .into(((MyViewHolder1)holder).cast_profile_picture);
          }
          else if (holder instanceof FooterViewHolder1)
          {
              ((FooterViewHolder1)holder).view_more.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View view)
                  {
                      Intent intent = new Intent(context,CastViewActivity.class);
                      intent.putParcelableArrayListExtra("LIST",FullArrayList);
                      context.startActivity(intent);
                  }
              });
          }
      }
  
      @Override
      public int getItemCount() {
          return this.detailArrayList.size();
      }
  }
  </code></pre>