I may not be very correct at syntax, but the following pseudo example may help you.
Suppose you have an interface named IShape and your local class, Rectangle, implements this interface. Now your method can create an object of type Rectangle and return it as IShape object.
See this:
interface IShape {
public void draw();
}
class
Test {
public IShape create () {
class Rectangle implements IShape {
public void draw () {
System.out.println ("I am draw of rectangle.");
}
}
return new Rectangle();
}
}
public class Main {
public static void main (
String args[]) {
IShape i = new Test().create();
i.draw();
}
}
Hope this helps...
Shah.