| Author |
Restrictions on the use of Fields during Initialization
|
Hemant Agarwal
Ranch Hand
Joined: Nov 21, 2005
Posts: 138
|
|
compile-time error results from the test program: whereas the following example compiles without error: Why is it so?
|
 |
Stuart Ash
Ranch Hand
Joined: Oct 07, 2005
Posts: 637
|
|
Because methods, including constructors, are "after" fields: they are considered separately from the field declarations. But between two fields, order matters.
|
ASCII silly question, Get a silly ANSI.
|
 |
Adam Richards
Ranch Hand
Joined: Nov 03, 2005
Posts: 133
|
|
|
To put it another way: Your first assignment refers to variable j, which hasn't been declared yet, so the compiler doesn't recognize it (j).
|
 |
 |
|
|
subject: Restrictions on the use of Fields during Initialization
|
|
|