USER DEFINED PACKAGES


SOURCE CODE:

classA.java

package package1;
public class classA
{
   public void displayA()
        {
         System.out.println("class A");
        }
 }

classB.java

package package2;
public class classB
{
    protected int m=100;
      public void displayB()
       {
        System.out.println("class B");
        System.out.println("m = "+m);
       }
}

PackageTest.java

import package1.*;
import package2.*;
class PackageTest
 {
  public static void main(String a[])
   {
    classA objA = new classA();
    classB objB = new classB();
    objA.displayA();
    objB.displayB();
   }
 } 

OUTPUT :

 class A

 class B

 m = 100
Previous
Next Post »

Still not found what you are looking for? Try again here.