Am I doing getters/setters the right way in Java?
- by Sergio Tapia
public class Persona {
int Codigo;
String Nombre;
public Persona(int Codigo, String Nombre){
this.Codigo = Codigo;
this.Nombre = Nombre;
}
public void setCodigo(int Codigo){
this.Codigo = Codigo;
}
public int getCodigo(){
return this.Codigo;
}
public void setNombre(String Nombre){
this.Nombre = Nombre;
}
public String getNombre(){
return this.Nombre;
}
}
Or is there a much shorter (realiable) way to do it?