Results 1 to 2 of 2
  1. #1
    harukia is offline Member
    Join Date
    Dec 2010
    Rep Power

    Default Problems adding new method to an extending abstract class

    In the program class:
    URL url = new URL("");
    extURLConnection c = new extURLConnection(url.openConnection());
    if (c.isConnected){

    In URLConnection I cant access the attribute connected (that shows if i got a connection or not). so I want to add a method that return that attribute.

    So I created a class called extURLConnection that extends URLConnection. As method connect() is abstract I must define this class as abstract. And this is here I get problems. Cause of this i cant initiate this class (as i written above). So how do I implement this isConnected method? Is it possible to do it in another way? I've read some thing about Interfaces, can it be done with that?

    class DpURLConnection extends URLConnection{
    DpURLConnection(URLConnection URLConn){

    public boolean isConnected(){
    return this.connected;

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power


    You can't do this, at least not without writing your own versions of HttpURLConnection etc.

    Why do you need to know about the connected flag? It's for internal use only.

Similar Threads

  1. Replies: 3
    Last Post: 08-13-2010, 04:57 AM
  2. Replies: 3
    Last Post: 09-16-2009, 09:27 PM
  3. Replies: 6
    Last Post: 02-11-2009, 10:51 AM
  4. Replies: 2
    Last Post: 11-21-2008, 12:20 AM
  5. Problems adding an external class
    By jan2321 in forum Eclipse
    Replies: 2
    Last Post: 11-06-2008, 10:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts