Access modifiers

Access modifiers are a specific part of programming language syntax used to facilitate the encapsulation of components.

C# extends the number of them to six,[2] while Java has four access modifiers, but three keywords for this purpose.

In Java, having no keyword before defaults to the package-private modifier.

A comparison of the keywords, ordered from the most restrictive to the most open, and their meaning in these three languages follows.

In Swift, there are five different access levels relative to both the source file in which the entity is defined and the module containing that source file.