Created
January 5, 2018 04:40
-
-
Save Velmm/f5fd51a7af44a80197e32dd103a0ae2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class User implements Parcelable{ | |
private int id; | |
private String name; | |
private int age; | |
public User(int id, String name, int age) { | |
this.id = id; | |
this.name = name; | |
this.age = age; | |
} | |
public User(Parcel parcel) { | |
this.id = parcel.readInt(); | |
this.name = parcel.readString(); | |
this.age = parcel.readInt(); | |
} | |
public int getId() { | |
return id; | |
} | |
public void setId(int id) { | |
this.id = id; | |
} | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public int getAge() { | |
return age; | |
} | |
public void setAge(int age) { | |
this.age = age; | |
} | |
@Override | |
public int describeContents() { | |
return 0; | |
} | |
@Override | |
public void writeToParcel(Parcel parcel, int i) { | |
parcel.writeInt(id); | |
parcel.writeString(name); | |
parcel.writeInt(age); | |
} | |
public static final Parcelable.Creator CREATOR = new Parcelable.Creator<User>() { | |
@Override | |
public User createFromParcel(Parcel parcel) { | |
return new User(parcel); | |
} | |
@Override | |
public User[] newArray(int i) { | |
return new User[i]; | |
} | |
}; | |
@Override | |
public String toString() { | |
return "User{" + | |
"id=" + id + | |
", name='" + name + '\'' + | |
", age=" + age + | |
'}'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment