I have a Fraction class using keyword this in my constructor:
public Fraction(int numerator, int denominator)
{
this.numerator = numerator;
this.
Using this
explicitly is mandatory if you wish to distinguish between a local variable and a member of the same name. Otherwise, it is optional.
Your constructor won't assign the passes values to the instance members without the this.
prefix, since the method arguments would hide the instance members. If you give the arguments different names, you can do without the this.
:
public Fraction(int num, int denom)
{
numerator = num;
denominator = denom;
...
}
Both multiply
versions are the same.