gzz-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Interfaces have no variables (was: Re: [Gzz] PEG ``vob_bgvob--humppa


From: Tuomas Lukka
Subject: Re: Interfaces have no variables (was: Re: [Gzz] PEG ``vob_bgvob--humppake``: Background Vob interface)
Date: Thu, 6 Mar 2003 09:24:31 +0200
User-agent: Mutt/1.4i

On Wed, Mar 05, 2003 at 09:55:16PM +0200, Alatalo Toni wrote:
> On Wed, 5 Mar 2003, Benja Fallenstein wrote:
> 
> > >   public boolean drawBorder = true;
> > Interfaces cannot have variables. The effect of this line is a constant
> > 'drawBorder' with value 'true.'
> 
> this is probably totally unrelated, but just a sidethought:
> does it ever make sense to have (such) constants in an interface?

Quite often, for the same reason as you have enums in C/C++:

        public interface Foo {
                int CRUNCHY = 1;
                int CHEWY = 2;
                int NUTRITIOUS = 4;

                Bar getSnack(int type);
        }

where you'd then call

        foo.getSnack(foo.CHEWY | foo.NUTRITIOUS);

        Tuomas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]