Is there anything like an Internal class in Java?

Svish picture Svish · May 12, 2011 · Viewed 36.2k times · Source

In C# you can mark a class as internal so that it is only accessible from within the same package. Is there anything similar in Java?

Answer

Bryan Kyle picture Bryan Kyle · May 12, 2011

You can create package-private classes by omitting the security modifier (public, private) from the class's declaration.

package com.sample;

class MyPackagePrivateClass
{
    ...
}