In the constructor: this will be a local variable
Java contains the following types of variables:
Instance Variables (Non-Static Fields):. In object-oriented programming, objects store their individual states in "non-static fields" that are declared without a static keyword. Each class object has its own set of values ββfor these non-static variables, so we can say that they are associated with objects (class instances). These variables are also known as instance variables. These variables take default values ββif not initialized.
Class variables (static fields): They all belong to the class, and not one of the objects can require its sole owner. Variables defined by the static keyword are shared by all objects. Here, the Objects do not retain individual significance, but they are forced to share it with each other. These variables are declared as "static fields" using the static keyword. The same set of values ββis always used for different objects of the same class. Thus, these variables are similar to global variables that are the same for all objects in the class. These variables take default values ββif not initialized.
Local variables: Variables defined in a method or block of code are called local variables. Access to these variables is possible only within the framework of a method or code block. These variables do not accept default values ββif they are not initialized. These values ββmust be initialized before using them.
Parameters: Parameters or arguments are variables used in method declarations.
source share