Why are all fields in an interface static and final? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why are all fields in an interface static and final?

29th Mar 2017, 5:39 PM
Sanjeev Dulal
Sanjeev Dulal - avatar
1 Answer
+ 15
First: Try to understand what an interface is and what it is intended to do. Hope this can help you: https://docs.oracle.com/javase/tutorial/java/IandI/createinterface.html To answer your questions: Static because you are not allowed to create an object of an interface, you can only implement or extend interfaces. Final because you don't want the fields used in an interface to be changed.
29th Mar 2017, 6:08 PM
Tashi N
Tashi N - avatar