0

Is it necessary for interface variables to be static or final?

14th May 2017, 3:06 PM
Gamer
Gamer - avatar
2 Answers
+ 3
If you declare a variable in an interface like this: public interface A { int a = 4; } Then "a" will be implicitly public, static and final. So it is valid: int i = A.a; But it isn't: A.a = 3;
14th May 2017, 3:27 PM
TamĂĄs Barta
TamĂĄs Barta - avatar
+ 1
static variables must be initialized first, before other variables final variables can be initialized in the constructor or in the object methods both exist only one per class static ones belong to the class, and don't need an intantiated object
14th May 2017, 3:23 PM
⏩▶Clau◀âȘ
⏩▶Clau◀âȘ - avatar