Creating a Package
Objectives :
  • Java heavily relies on packages
    • packages are the subdirectories containing classes and interfaces

Create a folder world

Create a folder ;

code simple and save it in a directory world

package world;
public class MathTesting

public int method(int n1)
return (n1+10);



Compiled OK

 Now write your testing code and save it in world's parent directory

import world.*;
public class TestPack
public static void main(String[] args)
MathTesting mt = new MathTesting();

System.out.println("Got it from world Test Pack\t"+ mt.method(12));


Compiled as

compile and run it