Advertisement
mauricioribeiro

Coala

May 13th, 2020
1,403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.43 KB | None | 0 0
  1. class Coala {
  2.  
  3.     private Integer valor = 0;
  4.  
  5.     public Integer getValor() {
  6.         return this.valor;
  7.     }
  8.  
  9.     public void setValor(Integer valor) {
  10.         this.valor = valor;
  11.     }
  12.  
  13.     public void funcaoDoFor () {
  14.         for (Integer i = 0; i < 10; i++) {
  15.             this.setValor(i);
  16.         }
  17.     }
  18. }
  19.  
  20. class App {
  21.  
  22.     public main() {
  23.  
  24.         Coala coala = new Coala();
  25.         coala.funcaoDoFor();
  26.  
  27.         System.out.println(coala.getValor()) // vai printar 9
  28.  
  29.     }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement