Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1.  
  2. public class TheWalkingDead {
  3.  
  4. Pessoa vivo;
  5.  
  6. public static void main(String[] args) {
  7. TheWalkingDead vida = new TheWalkingDead();
  8. vida.vivo=new Pessoa("José",vida);
  9. vida.vivo.fale();
  10. vida.vivo=null;
  11. while(vida.vivo==null){
  12. System.out.print(".");
  13. }
  14. vida.vivo.fale();
  15. }
  16.  
  17. }
  18.  
  19.  
  20. final class Pessoa {
  21.  
  22. String fala;
  23. TheWalkingDead vida;
  24.  
  25. public Pessoa(String nome,TheWalkingDead vida){
  26. this.vida=vida;
  27. this.fala = "Ola eu sou o "+nome;
  28.  
  29. }
  30.  
  31. public void fale() {
  32. System.out.println(fala);
  33. }
  34.  
  35. @Override
  36. protected void finalize() throws Throwable {
  37. System.out.println("\nRessucitando....");
  38. this.fala="Céeeerebro!!!";
  39. vida.vivo=this;
  40. }
  41.  
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement