Fields and methods structure

A field is basically composed of three main elements, an Access modifier , Data type and the Variable identifierit could also possess other types of key words, but they are all optional, except Data types which are mandatory. 
let's decompose the structure of a variable of integer type
so for the above example, we have two key words :
  • private: represents the private access modifier, which is simply a key word that controls the access scope of the variable from the outside.
  • int: represents the integer data type
  • variableName: the variable identifier or name, it must respect a certain identification pattern.

beware, A java class cannot contain multiple fields with the same name.

A java method is basically composed of two key words : an Access modifier and a Return type plus the Function identifier. A function could have a list of parameters but it is not mandatory.

let's decompose the setVariableName function.

from the above example, we have:

  • public: represents the public access modifier, which is simply a key word that controls the access scope of a variable from the outside.
  • void: represents the return data type, in this case, it is void which means return nothing.
  • setVariableName: the function identifier or name, it must respect a certain identification pattern.
  • (String variableName): The parameters list,which is optional, infinite and of various data types.

For example, the parameter list below contains four elements of various data types.

The return type could be any possible data type.The example below has two methods, one that returns an integer and another that returns boolean.

Each method has its signature, and it is what define the uniqueness of a function. A Class cannot contain two methods with the same signature. a method signature is composed of the Function identifier and The parameters list data types order.

For instance, the code below won't compile because the two methods have the same identifier and even though the parameter lists are not the same, they have the same data types order.

The examples below will compile because the parameters lists are different.
Here, The methods names are different.
Note that, the return type and access modifier are not part of the method signature.