D
D
Denis Kuznetsov2019-02-18 20:15:25
Java
Denis Kuznetsov, 2019-02-18 20:15:25

Why is it not necessary to specify an access modifier in interfaces?

When you try to specify an access modifier, the IDE prompts you to remove it with no other options. When implementing these methods inside classes, they are declared as public and, again, this cannot be changed. What is the reason for this, why exactly?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
illuzor, 2019-02-18
@DennisKingsman

The very concept of "interface" implies access from the outside. Therefore methods must be public.

A
aol-nnov, 2019-02-18
@aol-nnov

> When implementing these methods inside classes, they are declared as public and, again, this cannot be changed. What is the reason for this, why exactly?
Try to answer the question, why do you need an interface for private methods? Along the way, you will get an answer to your question.

D
Dmitry Alexandrov, 2019-02-18
@jamakasi666

This is due to the fact that the interface is always the "tip of the iceberg" which hides the implementation itself in the future. You can think of it as a point of interaction.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question