Types of Variables: Part 2
Explore the different types of variables in Java such as parameters, local, instance, and static variables. Understand variable scope, access modifiers like private, and proper naming conventions. This lesson helps you avoid common naming issues and write cleaner Java code with practical examples.
Parameters
We have seen different types of variables, and in some cases, we have seen a type of variable called parameters.
We need to remember one key thing about parameters. They are not classified as fields but classified as variables.
Coding example: 22
In the next two examples, we will see how parameters work. The signature for the main() method in Java also uses parameters.
Coding example: 23
The following code snippet deals with the same example using parameters. Along with it, we have also used class variables with static modifiers.