So, every variable (or field) must have a certain type. it could be int
, String
or whatever and you declare it as follows;
String myString;
int number;
In the same way calculator
is declared as a variable of type TaxCalculator
and you declare it as
TaxCalculator calculator;
1 Like
Thanks Paul but if we declare datatype as a String we can only give " sentences" for int only numbers. what we can only declare as TaxCalculator
You can do all the things with calculator that the TaxCalculator
class allows you to do. So if it has eg a calculateTax
method you can call it using calculator.calculateTax()
.
1 Like