Reputation: 2080
PostData
public class PostData {
@Expose
private String text;
@Expose
private Point point;
public class Point implements Serializable {
@Expose
private double longitude;
@Expose
private double latitude;
public Point(double longitude, double latitude) {
this.longitude = longitude;
this.latitude = latitude;
}
}
public PostData(String text, Point point) {
this.text = text;
this.point = point;
}
}
I want use it like
PostData postData = new PostData()
so i tried this like
PostData postData = new PostData("nqq", mpoint){
Point mpoint = new PostData.Point("13", "14");
};
But it has something wrong.
Actually i don't know how to deal with point
class.
Would you let me know example?
How can i use it in right way?
Upvotes: 0
Views: 34
Reputation: 4023
Rather than using inner class , separate PostData
and Point
Class
public class PostData {
@Expose
private String text;
@Expose
private Point point;
public PostData(String text, Point point) {
this.text = text;
this.point = point;
}
}
public class Point implements Serializable {
@Expose
private double longitude;
@Expose
private double latitude;
public Point(double longitude, double latitude) {
this.longitude = longitude;
this.latitude = latitude;
}
}
And then use like this way
Point point = new Point(13,14);
PostData postData = new PostData("nqq",point);
Upvotes: 2
Reputation: 1610
I don't know, but from your vague question I suppose you have problem initializing your point class object and passing it in your PostData class constructor.if yes? then this should work.
PostData.Point mpoint = new PostData.Point("13", "14");
PostData postData = new PostData("nqq", mpoint);
Upvotes: 1