Hi,
Jeffrey Schwab schrieb:
> Tobias Schröer wrote:
>
>> Gav schrieb:
>>
>>> I've seen an example like this:
>>>
>>> Class Foo {
>>> JButton one = new Jbutton("one");
>>> JButton two = new Jbutton("two");
>>>
>>> public Foo() {
>>> [...]
>>> }
>>> }
>>>
>>> How come that memers arre initialized in their declaration? Is it a
>>> JButton strageness? I'm a little confused.
>
>
> This is a feature of the Java language. It is as though the
> initialization code were inserted automatically at the beginning of
> every constructor.
Right. If you follow the call sequence with a debugger, it looks like this:
- call super constructor and initialize super type
- step through field declarations (and assignments)
- execute rest of constructor
> You can do this with any member variables. You also
> can provide initializers for static members right where they are
> defined, and the initialization code will be run when the class is loaded.
That's how constants (static final int CONST_INT = 1

are typically
initialized. Though, you should be able to set their values in the
static initializer, too. But that would be rather confusing, regarding
the extra code you'll have to write.
>> What excatly do you mean? Members are AFAIK the class' methods. On the
>> other hand you have fields - the variables. I think you mixed up the
>> names.
>
>
> Both fields and methods are members in Java.
That's right. It seems that *I* mixed up the terms a bit
Tobi