Why is an interface or abstract class useful? (or for what?)

So my question is: why use interfaces or abstract classes? Why are they useful and for what?

Where can I use them wisely?

+3
source share
2 answers

Interfaces allow you to express what a type does without worrying about how this is done. The implementation can be changed as desired without prejudice to customers.

Abstract classes are similar to interfaces, except that they provide reasonable default behavior for the methods in which it exists.

. Java, API. java.util .

+5

, , , / , , .

, , , , .

, Wikipedia , : , , , , , : , .

+3

Source: https://habr.com/ru/post/1745693/


All Articles