Instructions
- 1
Create a generic interface that contains an abstract method. For example:
interface ProxyInterface
public void method();
Create two classes that implement the ProxyInterface:
class P1 implements ProxyInterface
class P2 implements ProxyInterface
Create an implementation of "method()" in class "P2." Then, call the P2 version of "method()" from "P1." P1 now represents the proxy class:
class P1 implements ProxyInterface
P2 p = new P2();
public void method()
p.method();
class P2 implements ProxyInterface
public void method()
System.out.println("Hi");
No comments:
Post a Comment