0

CloseableHttpClient is an abstract class and it is mention in the document of HttpClientBuilder that it build instances of CloseableHttpClient. But we can't build the instances of abstract class ?

Class HttpClientBuilder --> Builder for CloseableHttpClient instances. CloseableHTTpClient is an abstract class.

I would like to know the meaning of the below line

CloseableHttpClient client = HttpClientBuilder.create().build()

The Build method is returning object of type CloseableHttpClient.

  • 2
    it just returns subclasses of `CloseableHttpClient` which *implement* the abstract methods – Lino Jun 29 '18 at 09:25
  • 3
    Yes, abstract classes can't be instantiated, but we can instantiate their non-abstract sub-classes. – Pshemo Jun 29 '18 at 09:26

0 Answers0