Creating Packages in java



import package1.ClassA;
class PackageTest1
{
public static void main(String args[])
{
ClassA A=new ClassA();
A.displayA();
}
}












/*Other  Package*/

import package1.ClassA;
import package2.*;


class PackageTest2
{
public static void main(String args[])
{
ClassA A=new ClassA();
ClassB B=new ClassB();
A.displayA();
B.displayB();

}
}


/*Other  Package*/

import package2.ClassB;
class ClassC extends ClassB
{
int n=20;
void displayC()
{
    System.out.println("ClassC");
    System.out.println("m :"+m);
    System.out.println("n: "+n);
}
}



class PackageTest3
{
public static void main(String args[])
{
ClassC C=new ClassC();
C.displayB();
C.displayC();

}
}


0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|