public class Toster {
interface Selector {
public String getText();
}
public Selector getSelector(int i)
{
if (i<0) {
class SelectorAdapter implements Selector {
public String getText() { return "Selector 1"; }
}
return new SelectorAdapter();
}
else {
class SelectorAdapter implements Selector {
public String getText() { return "Selector 3"; }
}
return new SelectorAdapter();
}
}
public static void main(String[] args) {
Toster toster = new Toster();
for (int i=-1; i<1; i++)
{
System.out.println(toster.getSelector(i).getText());
}
}
}
|