Why are interface variables static and final by default in Java?
What meaning would an instance of an interface have? By DEFINITION an interface is abstract and cannot be instantiated. Thus no instance variables, static only.
Because anything else is part of the implementation, and interfaces cannot contain any implementation.
From www.codestyle.org:
Interface variables are static because Java interfaces cannot be instantiated in their own right; the value of the variable must be assigned in a static context in which no instance exists. The final modifier ensures the value assigned to the interface variable is a true constant that cannot be re-assigned by program code.
static - because Interface cannot have any instance. and final - because we do not need to change it.
Because Sun incorrectly decided developers didn't need a const
keyword.