Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #30629

Why base class's static method shows up in derived class?

Newsgroups comp.lang.java.programmer
Date 2015-01-04 23:52 -0800
Message-ID <e8dd9f53-8064-4e8b-bedf-809bddecfe8c@googlegroups.com> (permalink)
Subject Why base class's static method shows up in derived class?
From Stone Zhong <stone.zhong@gmail.com>

Show all headers | View raw


Hi there,

Can anyone share some experiences with this weird behavior:

With the code snipped below:

        for (Method method: HttpClientContext.class.getMethods()) {
            if (method.getName().equals("create")) {
                System.out.printf("%s%n", method);
            }
        }


I got output:
public static org.apache.http.client.protocol.HttpClientContext org.apache.http.client.protocol.HttpClientContext.create()
public static org.apache.http.protocol.HttpCoreContext org.apache.http.protocol.HttpCoreContext.create()


HttpClientContext derived from HttpCoreContext. Both class has a static method "create" with no parameter. 

Why HttpCoreContext.create shows up as HttpClientContext's method? I am expecting only "public static org.apache.http.client.protocol.HttpClientContext org.apache.http.client.protocol.HttpClientContext.create()" to show up, am I missing anthing?

Thanks,
Stone

Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Why base class's static method shows up in derived class? Stone Zhong <stone.zhong@gmail.com> - 2015-01-04 23:52 -0800
  Re: Why base class's static method shows up in derived class? Patrick Roemer <sangamon@netcologne.de> - 2015-01-05 13:07 +0100
  Re: Why base class's static method shows up in derived class? v_borchert@despammed.com (Volker Borchert) - 2015-01-05 22:12 +0000

csiph-web