You are here: Home / Topics / Program to explain Importing Package in Java

Program to explain Importing Package in Java

Filed under: Java on 2023-09-17 15:35:29

// Program to explain Importing Package.

package  Pack1;

public class  First
{
public void view( )
{
 System.out.println( "This is First Class." );
}
}

// Second File as (ImportPack1.java in current folder) :

import Pack1.*;

public class  ImportPack1
{
public static void main( String args[ ] )
{
 First f = new First();
 f.view();
}
}


Output:

This is First Class.


About Author:
M
Mr. Dubey     View Profile
Founder of MCQ Buddy. I just like to help others. This portal helps students in getting study material free. Share your stuff here so that others can get benefitted.