Wednesday, April 24, 2019

sub package



step1:: go to D:\p1\p2

step2: p.java


package p1.p2;
import java.util.Scanner;
public class p
{
public void f(int x,int y){
System.out.println(x);
System.out.println(y);
}
}

step3:
D:\

step4 ::cl5.java

import p1.p2.p;
import java.util.Scanner;
class cl4 extends p
{
}


public class cl5
{
public static void main(String args[])
{
cl4 ob=new cl4();
ob.f(2,3);
}
}



step5:

D:\>cd p1

D:\p1>cd p2

D:\p1\p2>javac p.java

D:\p1\p2>cd ..

D:\p1>cd ..

D:\>javac cl5.java

D:\>java cl5
2
3

D:\>java cl5

No comments:

Post a Comment