- It is a namespace that organizes a set of related classes and interfaces.
- We can group our different classes under different packages.
- Each package name is separated by a . and each of this separated unit in name is a folder under src in sequential order.
- Class is stored in last folder.
- A package also provides a separate namespace or an identity to the owner of the class.
package javaimplant.interfaces;
public class InterfaceExample
{
public static void main(String args[])
{
Animal a1=new Dog();
Animal a2=new Cat();
a1.makeSound();
a2.makeSound();
}
}
- Above class is under javaimplant.interfaces package i.e it is under src/javaimplant/interfaces folder in project
No comments:
Post a Comment