【发布时间】:2012-02-25 08:16:15
【问题描述】:
public final class City
{
public final long id;
public final String name;
public final double latitude;
public final double longitude;
public City(long id, String name, double lat, double lng)
{
this.id = id;
this.name = name;
this.latitude = lat;
this.longitude = lng;
}
public static City fromJsonObject(JSONObject json) throws JSONException
{
return new City(json.getLong(WebApi.Params.CITY_ID),
json.getString(WebApi.Params.CITY_NAME),
json.getDouble(WebApi.Params.LATITUDE),
json.getDouble(WebApi.Params.LONGITUDE));
}
}
这是我的课。我想在我的另一个类中访问这个类的值;我怎么做? (纬度、经度、cityid和城市名称的值)
【问题讨论】:
-
你还没有初始化你的最终变量。你的代码是如何编译的??
-
@ShashankKadne 你在哪里看到决赛没有初始化?或者,也许 OP 在您提出问题后编辑了他的构造函数?
标签: java class object constructor