Step1:
First Create folder and give name of package to it.
eg: mypack
Step 2:
Set path to folder
Step 3:
Create first class to include in package:
Idk.java
package mypack;
public class Idk
{
public void Hi()
{
System.out.println("Hello JAVA");
}
}
Save as in mypack folder
Step 4:
Write a program to import package
import mypack.Idk;
class New
{
public static void main(String ar[])
{
Idk i=new Idk();
i.Hi();
}
}
Compile And Run the Program:
Output:
First Create folder and give name of package to it.
eg: mypack
Step 2:
Set path to folder
Step 3:
Create first class to include in package:
Idk.java
package mypack;
public class Idk
{
public void Hi()
{
System.out.println("Hello JAVA");
}
}
Save as in mypack folder
Step 4:
Write a program to import package
import mypack.Idk;
class New
{
public static void main(String ar[])
{
Idk i=new Idk();
i.Hi();
}
}
Compile And Run the Program:
Output:
Comments
Post a Comment
If you have any query, please let us know