Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Java, The constructor is undefined

I manually added constructor, but still getting 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);
    }
}

I’m creating new object with:

new HttpResponseExtended()

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The constructor you defined takes an argument, try using:

new HttpResponseExtended(res);

Where res is of type HttpResponse<String>

If you want to instantiate the class without passing any argument, you need to define a constructor that doesn’t take any arguments.

public HttpResponseExtender() { }

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading