我手动添加了构造函数,但仍然得到 The constructor HttpResponseExtended() is undefined
public class HttpResponseExtended {
HttpResponse<String> response;
public HttpResponseExtended(HttpResponse<String> res) {
this.response = res;
}
public JSONObject json() {
return new JSONObject(response);
}
}
我正在创建新对象:
new HttpResponseExtended()
如果添加任何类型的构造函数,那么您将不再获得默认的空构造函数。但你可以添加一个。喜欢,
public class HttpResponseExtended {
HttpResponse<String> response;
public HttpResponseExtended(HttpResponse<String> res) {
this.response = res;
}
public HttpResponseExtended() {
// Of course, now you need a default response...
}
public JSONObject json() {
return new JSONObject(response);
}
}