What is behind the design decision so that the static method returns a private class? For example Collections.synchronizedList ()

I wanted to extend the SynchronizedList class, but found it private.

Why was it designed this way?

+4
source share
1 answer

This is because the person who developed it does not want you to expand it.

The exact reason for this is known only to the designer (s), but consider the tip in Effective Java 2nd Ed Item 17:

Design and document to inherit or prohibit it.

, , . Java , , , .

, , " ". Collections.Synchronized* : ; , . ( , , , 1, ).

, -: , Synchronized*, Synchronized* . Synchronized* - , .

, .

+3

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


All Articles