Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why is interface constant static  RSS feed

 
Prabu JayaPandian
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We declare interface constants as public static and final. I understand why we declare them as public and final. But why do we make them static?
[ August 04, 2008: Message edited by: Prabu JayaPandian ]
 
Rob Spoor
Sheriff
Posts: 20904
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because if they weren't static, they would belong to instances. First of all, that means data replication - all instances of all implementing classes will have the exact same constant variables.
Second of all, instance variables are part of the implementation, and interfaces can have no implementation.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!