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:
S
Shyam Dubey     View Profile
If you are good in any field. Just share your knowledge with others.