What is the default access specifier in Java?

bennedich picture bennedich · Aug 20, 2010 · Viewed 145.3k times · Source

I just started reading a Java book and wondered; which access specifier is the default one, if none is specified?

Answer

KeatsPeeks picture KeatsPeeks · Aug 20, 2010

The default visibility is known as “package-private” (though you can't use this explicitly), which means the field will be accessible from inside the same package to which the class belongs.

As mdma pointed out, it isn't true for interface members though, for which the default is "public".

See Java's Access Specifiers