I have a class Den implementing the Serializable interface:
public class Den implements Serializable {
private double id;
private String name;
public Den(double id, String name){
this.id = id;
this.name = name;
}
public double getId() {
return id;
}
public void setId(double id) {
this.id = id;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
}
I can send a Den instance in an Intent like this:
Intent intent = new Intent(context, NewActivity.class);
intent.putExtra("OBJECT_KEY", new Den(20.2, "JOHN"));
startActivity(intent);
And receive it in another Activity like this:
Intent intent = getIntent();
Den den = (Den) intent.getSerializableExtra("OBJECT_KEY");
Now my question is: Why do I need to implement the Serializable interface on Den, but not on primitive data types like int, float or String? What is happening internally?