| Author |
interface variable must be initialized ?
|
Harikrishna Gorrepati
Ranch Hand
Joined: Sep 23, 2010
Posts: 422
|
|
interface P00_Constructor5_Ask
{
int answer; //The blank final field answer may not have been initialized..Why not taking default value ?
}
|
OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9191
|
|
|
final fields don't get a default value, you have to assign them a value explicitly...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
Harikrishna Gorrepati
Ranch Hand
Joined: Sep 23, 2010
Posts: 422
|
|
|
Got it..thanks Ankit
|
 |
Arjun Srivastava
Ranch Hand
Joined: Jun 23, 2010
Posts: 431
|
|
final variables must be initialize on the same line or at the end of constructor.
because interface cannot have constructors so final variables have to be initialize on the same line on which it is being declared.
|
SCJP 6 | FB : Java Certifications-Help. | India Against Corruption
|
 |
 |
|
|
subject: interface variable must be initialized ?
|
|
|