What is the purpose of different variable names in instance fields and constructor method?

Why does one need to set one name in instance fields and another as parameter and then declare the instance field name equal to the parameter name within the constructor method?

You don’t have to use different names, but I think the point of the lesson is you can…As for why it’s done, the parameters of the constructor are only really used to signal to the compiler (and other coders) that you need to pass in some values when creating a new Store object. Therefore, the parameters on their own can’t be used outside of the constructor, but if you assign them to class variables, then those values can be used…

1 Like