Probably we used to declare the method and class as a public .
But the there is also the classes where there is no any public
or any private .
We can make two or many classes in a single class file.
* But when declaring numerous class the class file must contain
at least one public class whose class must match to class file

A simple class containing two class with it’s package :
package Test1;
public class Test1{…}
class Test2{…}[/sourcecode]
Another class containing with two class with pacakage:
[sourcecode=’java’] //package

package X;
public class X{….}
class Y{….}[/sourcecode]
At this time we can’t instantiate any variable from to Because it’s been blocked by a wall of Package.
A structure diagram of above file will looks like this:


We can make a link between these files:
By importing its package from one class to another.
import X.*;

package Test1;
public class Test1{…}
class Test2{…}[/sourcecode]
Now the structure looks like this:

The above code doesn’t care about the non public class Y of because of it’s non public feature. The public class can’t make a object even if we import the package X.