davegimo

donato1

Mar 15th, 2021
568
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Persona {
  2.    
  3.     private String nome;
  4.     private int eta;
  5.     private String citta;
  6.    
  7.     public Persona(String n, int e, String c) {
  8.         this.nome = n;
  9.         this.eta = e;
  10.         this.citta = c;
  11.     }
  12.    
  13.    
  14.     public int getEta() {
  15.         return this.eta;
  16.     }
  17.    
  18.     public void setEta(int newEta) {
  19.         this.eta = newEta;
  20.     }
  21.  
  22.    
  23.  
  24.      public static void main(String []args){
  25.      
  26.       Persona p = new Persona("Davide", 25, "Pisa");
  27.       System.out.println(p.getEta());
  28.      
  29.       p.setEta(15);
  30.       System.out.println(p.getEta());
  31.      
  32.      }
  33. }
RAW Paste Data