private method and now property ?
Backward Compatibility
and ...
please help me to understand it
Could you ask clearly
Why java add private method and we can define Variable in interface
This is explanation about all access modifier
Yes ..
I believe you are asking why the below were allowed, 1, Default Methods in Interfaces 2, Private Methods in Interfaces 3, Variables in Interfaces Right?
yes i know 1, Default Methods in Interfaces but 2, Private Methods in Interfaces 3, Variables in Interfaces no
The use case for the private methods in interfaces are to be called by default (and static) methods since no other class can call them. the point is to hide a logic from classes implementing the interface (encapsulation) variables in an interface are all final and static (because interface cannot be instantiated) and the use case is to have a shared property between classes implementing it.
Обсуждают сегодня