0

Recently, I was trying to use interfaces to store some information which I needed to use globally. Initially, I was going to make every class which needed the information implement this interface to access the data. However, I eventually realized the enormously better solution of using the fact that variables are final and static to just get the data from a static call.

Through this journey I now have a question. When a class implements an interface with variables, does each class independently store the variables in new memory, or does it just get stored once in the interface. Kind of a weird question which I couldn't find an answer to.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197

1 Answers1

0

Static fields are stored once within their class or interface, they are not duplicated in every instance

peterz
  • 306
  • 1
  • 3