Instance variables declared in an Interface are treated as 'final' type by default. When you implement an interface containing Instance Variables in your class, you can't modify the values of Instance variables belonging to Interface in your class.
Lets implement this on Eclipse IDE:
(First lets print the implemented interface variables)
1. Create Interface 'Interface1' containing few instance variables as shown below:
5. Observe that the output is displayed in the console as shown below:
Click here to download the project containing the 'Interface1', 'ClassOne' and 'InterfaceVariablesDemo' files used in this post (You can download the project and import into Eclipse IDE on your machine)
(Now lets find out what happens when we modify the Instance variable of Interface in 'ClassOne' class)
1.In 'ClassOne' class of above project, create another method 'printModifiedValues( )' and try to modify the values of instance variables of 'Interface1' as shown below:
Please comment below to feedback or ask questions.