Friday, 29 January 2016

Why interface cannot have instance variables?

Interface variables are static final 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.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...