I was reading my AP cs book and it talked about three types of variables:
•Instance variables
•Local variables
•Parameters
Instance variables are visible throughout the class etc... Parameters are only usable within the method and so are local variables . . .
Therefore my question is why would they classify Parameters and Local variables as different categories of variables if they contain the same scope. . . Despite the different uses of them.
Because they don't necessarily have the same scope.
Take this case:
The Java Language Specification identifies 7 types of variables. Their descriptions are
You should also read about variable scope, which describes where some named entity can be used within your application.
As you can see from the descriptions above, they do not contain the same scope and therefore need to be differentiated.
Local variables are initialized in the method, while parameters are passed into the method.