default

If we do not mention any access modifier, our Java class automatically thinks it has a default access modifier. If it is default, that means you can access this method anywhere in your package. But if you go out of this package, then you cannot access this method. Even if we import the package.classname into our new package, we will not be able to access this method if we have not specified it as public. If you don't specify it, then by default it thinks it's a default access modifier. The default access modifier can be accessed anywhere in the package, but not outside it.

In the Packages section, we imported this package and we tried to use it. As you can see in the following screenshot, there is an error showing up in line 15:

Get Hands-On Automation Testing with Java for Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.