[CALUG] java code in eclipse: abstract URLConnection

Walt Smith waltechmail at yahoo.com
Tue Mar 29 20:30:35 EDT 2011


Hi all,

I read forum where I was trying to figure out
why I +can+ make an object from an abstract class URLConnection.
code and example at end-- the code isn't mine, but the Q is;

A poster made the following quote:

.....find that the actual implementation of them is found 
in non-core java classes:


It was not mentioned what "non-core java classes" meant that I could find.
It sounds as though there is a "URLConnection" class in two different
"namespaces" in distributed libraries ?

Here is a posted non-understandable explanation:
I think Sun has its internal implementation of non-abstract sub-class of class "HttpURLConnection". When we get a handle of "HttpURLConnection", what we actually retrieved is its internal implementation of non-abstract sub-class of class "HttpURLConnection".

someone good at decyphering is needed.....


thx,

Walt...........

===================================

Code:

import java.net.*;

public class URLWhat{

  public static void main(String[] argv)throws Exception{
  
    URL u = new URL("http://www.google.com");
    URLConnection uc = u.openConnection();
    System.out.println(uc.getClass());
  }
}


RUN:
c:\javawork>java URLWhat
class sun.net.www.protocol.http.HttpURLConnection

c:\javawork> 






More information about the CALUG mailing list