How to Hide Class in a Package?

https://www.computersprofessor.com/2016/12/how-to-hide-class-in-package.html
Hiding classes:
When we import a package using astric(*),all public classes are imported.however
,we may preffer to “not import”certain classes.i.e,we may like to hide these
classes from accessing from outside of the package.such classes should be
declared”not public”.
EX:
package p1;
public class X
{
Body of X
}
class Y
{
Body of Y
}
Here,
the class y which is not declared public is hidden from out side of the
package p1. this class can be seen and used only by other classes in the same
package note that a java source file should contain only one public class and
may include any number of non public classes.
Now ,consider the following code ,which
imports the package p1 that contains classes X and Y:
import
p1.*;
X
objectX;
Y
objectY;
Java compiler would generate an error
message for this code because the class Y,which has not been declared public,is
not imported and therefore not available for creating its objects.