0

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

14th May 2017, 3:06 PM
Gamer
Gamer - avatar
2 ответов
+ 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