So I know how useful keyword this is in constructor, when class member and parameter uses the same name.
Do people commonly use this outside of constructor to access instance variable/member and function? Is this a good practice? Should I keep using this keyword or should I not use it?
class Test {
private int num = 0;
Test(int num) {
this.num = num;
}
public int getNum() {
return this.num; // I could write num;
}
public void doSomething() {
System.out.println(this.getNum()); // I could have just invoked getNum()
}
}