It is also possible to create sub
packages for the main package.
Syntax: package pack1.pack2;
where pack1 is the main package and
pack2 is the sub package.
Example:
package pack1;
public class x
{
public
void show()
{
System.out.println("Super");
}
}
package pack1.pack2;
public class y
{
public
void display()
{
System.out.println("Sub");
}
}
import pack1.x;
import pack1.pack2.y;
class che
{
public
static void main(String[] args)
{
x
obj=new x();
obj.show();
y
obj1=new y();
obj1.display();
}
}
No comments:
Post a Comment