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


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

Re: multiple inheritance in Java

Date 2013-07-03 14:49 +0100
From lipska the kat <"nospam at neversurrender dot co dot uk">
Organization Trollbusters 3
Newsgroups comp.lang.java.programmer
Subject Re: multiple inheritance in Java
References (2 earlier) <multiple-inheritence-20130702041514@ram.dialup.fu-berlin.de> <61a00488-56ab-4452-bb3c-74e79d1a7d81@googlegroups.com> <6h8daa-4g3.ln1@s.simpson148.btinternet.com> <hYadnW-CWvwPj0nMnZ2dnUVZ8uSdnZ2d@bt.com> <mikdaa-un6.ln1@s.simpson148.btinternet.com>
Message-ID <Zq6dnQkaj4dPtknMnZ2dnUVZ7tqdnZ2d@bt.com> (permalink)

Show all headers | View raw


On 03/07/13 14:12, Steven Simpson wrote:
> On 03/07/13 13:01, lipska the kat wrote:
>> It is possible to add state to an interface so that it is *almost* a
>> class [...]
>>
>> interface Foo{
>>
>>    /* explicitly static and final */
>>    Integer i = 0;
>>    State state = new State(); /* final reference, mutable instance */
>>
>>    default public void doFoo(Integer x){
>>        //i = 10; /* illegal */
>>        Integer y = x + i;
>>        state.a = y + y;
>>        System.out.println("doingFoo, i + x is " + y);
>>        System.out.println("doingFoo, accessing state state.a is " +
>> state.a);
>>    }
>> }
>
> Foo.state is effectively class state, rather than instance state, isn't
> it?  Some possibilities were discussed here:
>
> <http://mail.openjdk.java.net/pipermail/lambda-dev/2012-July/005165.html>

I don't know, I've only recently started looking at this.
IIUC (which is by no means certain at this point) then state is a class 
variable that is shared by all instances of all classes that implement 
the Foo interface ... or is it a class variable that is shared by all 
instances of a given class that implements Foo and a different class 
that implements Foo would have it's own copy of state shared by all it's 
instances ... that seems more likely, I suppose some more investigation 
is required

I can't say I've ever really had much use for variables in interfaces 
before so I've never really given this sort of thing much thought.

lipska

-- 
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun

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


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