Posted by: Sourav | April 21, 2015

A Package example in Java

Make a folder called test package,create 2 sub folder under it named test1 and test2.

Create under test1 contains

package test1;

public class a{
public int i=2;

public static void main(String args[])

//static int i=2;


Create a under test2

package test2;
import test1.a;

class b{
int k=90;
public static void main( String args[])
a A=new a();

int j=35;

Now in cmd go to test packages folder

javac test1\

java test1.a

javac test2\

java test2.b


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


%d bloggers like this: