Example I have the class Metodo
:
public class Metodo {
private String string;
public String mostrar(String nome, String sobrenome){
this.string = "Nome: " + nome + "Sobrenome: " + sobrenome;
return string;
}
public void show(){
System.out.println(this.string);
}
}
And the class that tests this method:
package testarMetodo;
public class Teste {
public static void main(String[] args) {
Metodo metodo = new Metodo();
metodo.mostrar("Aline", "Gonzaga").show();
}
}
It just does not work. I just wanted to get the return of the other method and have display with the method show()
.
How can I do this?