interface Produto {
}
class Revista implements Produto {
@Override
public void exibirNome
(String nome
) { System.
out.
println("Exibindo revista de nome: " + nome
); }
}
class Teste {
private Produto produto;
public Teste(Produto produto) {
this.produto = produto;
}
public Produto getProduto() {
return produto;
}
@Override
produto.exibirNome(nome);
return nome;
}
}
class Ideone {
public static void main
(String[] args
) { Produto p = new Revista();
Teste teste = new Teste(p);
}
}
//https://pt.stackoverflow.com/q/172121/101
aW50ZXJmYWNlIFByb2R1dG8gewogICAgdm9pZCBleGliaXJOb21lKFN0cmluZyBub21lKTsKfQogCmNsYXNzIFJldmlzdGEgaW1wbGVtZW50cyBQcm9kdXRvIHsKICAgIEBPdmVycmlkZQogICAgcHVibGljIHZvaWQgZXhpYmlyTm9tZShTdHJpbmcgbm9tZSkgewogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiRXhpYmluZG8gcmV2aXN0YSBkZSBub21lOiAiICsgbm9tZSk7CiAgICB9Cn0KIApjbGFzcyBUZXN0ZSB7CiAgICBwcml2YXRlIFByb2R1dG8gcHJvZHV0bzsKICAgIFN0cmluZyBub21lOwogCiAgICBwdWJsaWMgVGVzdGUoUHJvZHV0byBwcm9kdXRvKSB7CiAgICAgICAgdGhpcy5wcm9kdXRvID0gcHJvZHV0bzsKICAgIH0KIAogICAgcHVibGljIFByb2R1dG8gZ2V0UHJvZHV0bygpIHsKICAgICAgICByZXR1cm4gcHJvZHV0bzsKICAgIH0KIAogICAgQE92ZXJyaWRlCiAgICBwdWJsaWMgU3RyaW5nIHRvU3RyaW5nKCkgewogICAgCXByb2R1dG8uZXhpYmlyTm9tZShub21lKTsKICAgICAgICByZXR1cm4gbm9tZTsKICAgIH0KfQogCmNsYXNzIElkZW9uZSB7CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKQl7CgkJUHJvZHV0byBwID0gbmV3IFJldmlzdGEoKTsKICAgICAgICBUZXN0ZSB0ZXN0ZSA9IG5ldyBUZXN0ZShwKTsKICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4odGVzdGUpOwoJfQp9CgovL2h0dHBzOi8vcHQuc3RhY2tvdmVyZmxvdy5jb20vcS8xNzIxMjEvMTAx