Link to home
Start Free TrialLog in
Avatar of zizi21
zizi21

asked on

toString method

Hi,

In the java classes, is it common to write this.variable in the toString method when you are overriding it. Why is "this" written? You are able to access the variable without this.
i.e
public class test{
private String a;

@Override
      public String toString() {
return this.a;
}
}
ASKER CERTIFIED SOLUTION
Avatar of Paul Jackson
Paul Jackson
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zizi21
zizi21

ASKER

Thanks !