Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #24644
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.albasani.net!.POSTED!not-for-mail |
|---|---|
| From | Sebastian <news@seyweiler.dyndns.org> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: multiple inheritance in Java |
| Date | Fri, 05 Jul 2013 08:04:38 +0200 |
| Organization | albasani.net |
| Lines | 68 |
| Message-ID | <kr5nl5$s6u$1@news.albasani.net> (permalink) |
| References | <multiple-inheritance-20130702021857@ram.dialup.fu-berlin.de> <kqtbe7$mth$1@dont-email.me> <multiple-inheritence-20130702041514@ram.dialup.fu-berlin.de> <kqtjfn$uf0$1@dont-email.me> <multiple-inheritance-20130702120045@ram.dialup.fu-berlin.de> <kqufqd$52m$1@dont-email.me> <51d5ea42$0$302$14726298@news.sunsite.dk> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Trace | news.albasani.net ujah/vbx0O9qm/OEAPqiAytN7fZYIW8hAnvUuQcvL8Nb1j4sIX0xXeCnO+eQ8fg2KXN3Fwte5WgZe8My9gwQjQ== |
| NNTP-Posting-Date | Fri, 5 Jul 2013 06:04:21 +0000 (UTC) |
| Injection-Info | news.albasani.net; logging-data="3aum3IhiTn09gQ1Vv9vNhzExGos7qpkaagY2oP/XC8l77foAfZETrcQ5mYyZj/7iQw6EjUUvqzJCqCczMKMuKuqUdZ0SEWNZ8G7ZUAlbdcN+HAZg90qH2bt9icNM2vYg"; mail-complaints-to="abuse@albasani.net" |
| User-Agent | Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 |
| In-Reply-To | <51d5ea42$0$302$14726298@news.sunsite.dk> |
| Cancel-Lock | sha1:oKqEQ4/f8KcbZxWue+PwXtwLSyg= |
| Xref | csiph.com comp.lang.java.programmer:24644 |
Show key headers only | View raw
Am 04.07.2013 23:33, schrieb Arne Vajhøj:
[snip]
> I understand his »poor man's multiple inheritance«.
[snip]
>
> But it still has nothing to do with public field vs accessor
> as the above also be done as (and IMHO should be done as):
>
> public class A {
> public void a() { ... }
> }
>
> public class B {
> public void b() { ... }
> }
>
> public class C {
> private A a;
> private B b;
> public C() {
> a = new A();
> b = new B();
> }
> public A getA() {
> return a;
> }
> public B getB() {
> return b;
> }
> }
>
> C o = new C();
> o.getA().ma();
> o.getB().mb();
>
> Arne
Or even better, if you really want inheritance, use inner classes:
public class C {
private CA a;
private CB b;
private class CA extends A {
@Override
public void a() { ... }
}
private class CB extends B {
...
}
public C() {
a = new CA();
b = new CB();
}
public A asA() {
return a;
}
public B asB() {
return b;
}
}
-- Sebastian
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: multiple inheritance in Java Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-07-01 21:52 -0400
Re: multiple inheritance in Java Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-07-02 00:09 -0400
Re: multiple inheritance in Java Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-07-02 08:13 -0400
Re: multiple inheritance in Java Arne Vajhøj <arne@vajhoej.dk> - 2013-07-04 17:33 -0400
Re: multiple inheritance in Java Sebastian <news@seyweiler.dyndns.org> - 2013-07-05 08:04 +0200
Re: multiple inheritance in Java Jeff Higgins <jeff@invalid.invalid> - 2013-07-02 13:17 -0400
Re: multiple inheritance in Java Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-07-02 13:40 -0400
Re: multiple inheritance in Java Jeff Higgins <jeff@invalid.invalid> - 2013-07-02 14:29 -0400
Re: multiple inheritance in Java Jeff Higgins <jeff@invalid.invalid> - 2013-07-02 15:12 -0400
Re: multiple inheritance in Java Arne Vajhøj <arne@vajhoej.dk> - 2013-07-04 17:23 -0400
Re: multiple inheritance in Java Arne Vajhøj <arne@vajhoej.dk> - 2013-07-04 17:25 -0400
Re: multiple inheritance in Java Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-07-02 15:44 -0400
Re: multiple inheritance in Java Jeff Higgins <jeff@invalid.invalid> - 2013-07-02 16:28 -0400
Re: multiple inheritance in Java Jeff Higgins <jeff@invalid.invalid> - 2013-07-02 16:44 -0400
Re: multiple inheritance in Java Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-07-02 17:13 -0400
Re: multiple inheritance in Java Jeff Higgins <jeff@invalid.invalid> - 2013-07-02 22:12 -0400
Re: multiple inheritance in Java Lew <lewbloch@gmail.com> - 2013-07-02 11:53 -0700
Re: multiple inheritance in Java Steven Simpson <ss@domain.invalid> - 2013-07-03 10:46 +0100
Re: multiple inheritance in Java lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-07-03 13:01 +0100
Re: multiple inheritance in Java Steven Simpson <ss@domain.invalid> - 2013-07-03 14:12 +0100
Re: multiple inheritance in Java lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-07-03 14:49 +0100
Re: multiple inheritance in Java Arne Vajhøj <arne@vajhoej.dk> - 2013-07-06 22:19 -0400
Re: multiple inheritance in Java Arne Vajhøj <arne@vajhoej.dk> - 2013-07-04 17:36 -0400
Re: multiple inheritance in Java Gene Wirchenko <genew@telus.net> - 2013-07-05 11:01 -0700
csiph-web