openConnection();
creates an instance of the implementation of the URLConnection class (sun.net.www.protocol.http.HttpURLConnection @Credit is sent to Sotirios).
Based on javadoc :
If the URL protocol (for example, HTTP or JAR) has a public specialized subclass of URLConnection that belongs to one of the following packages or one of its subpackages: java.lang, java.io, java.util, java.net, the connection will be associated with this subclass . For example, for HTTP, an HttpURLConnection will be returned , and for a JAR, a JarURLConnection will be returned.
source share