Metode & Parametri

class Broasca {
    private String nume;
    private int varsta;
     
    public void setNume(String nume) {
        this.nume = nume;
    }
     
    public void setVarsta(int varsta) {
        this.varsta = varsta;
    }
     
    public String getNume() {
        return nume;
    }
     
    public int getVarsta() {
        return varsta;
    }
     
    public void setInfo(String nume, int varsta) {
        setNume(nume);
        setVarsta(varsta);
    }
}
 
public class App {
 
    public static void main(String[] args) {
     
        Broasca broasca1 = new Broasca();
         
        //broasca1.nume = "Ninja";
        //broasca1.varsta = 1;
         
        broasca1.setNume("Ninja");
        broasca1.setVarsta(1);
         
        System.out.println(broasca1.getNume());
        System.out.println(broasca1.getVarsta());
    }
 
}
Output: Ninja
        1