Java language convention; getters/setters
- by Skogen
Public class Example {
private int number;
public Example(int number){
this.number = number;
}
public int getNumber(){
return number;
}
public void setNumber(int number){
this.number = number;
}
public static void main(String[] args){
Example e = new Example(5);
What is preffered when accessing a variable within its own class;
"e.number" or "e.getNumber()" ?