Table of Contents
Program to create package in Java
A Java program to create package.
Java program to create package
File location : Root/Animal/Behaviours.java
package Animals; //itvoyagers.in public interface Behaviours { void type(); void food(); }
File location : Root/DemoPackage.java
import Animals.*; class Elephant implements Behaviours { public void type() { System.out.println("n Elephant is of Viviparity type."); } public void food() { System.out.println("n Elephant is of Herbivorous type."); } } //itvoyagers.in class DemoPackage { public static void main(String[] args) { Elephant e1 = new Elephant(); e1.type(); e1.food(); } }
Output

PRACTICALS/PRACTICE PROGRAM IN Java
CHECKOUT OTHER RELATED TOPICS
We are aiming to explain all concepts of Java in easiest terms as possible.

ITVoyagers
Author