What is getter and setter in android development.
And what is the use of @Expose in GSON.
@SerializedName("url")
@Expose
private String url;
And what is the use of @Expose in GSON.
@SerializedName("url")
@Expose
private String url;
Getter = accessing variable to be able to use
Setter = assigning a new value to variable
@Expose
is used to decide whether a variable will be exposed for serialization/deserialization or not
In Java, getter and setter are two conventional methods that are used for retrieving and updating value of a variable.
Something like:
public class Example {
private int number;
public int getNumber() {
return this.number;
}
public void setNumber(int number) {
this.number = number;
}
}
@Expose is an annotation. The official doc:
An annotation that indicates this member should be exposed for JSON serialization or deserialization.