DEV Community

Milena
Milena

Posted on

Static methods and member variables

What are parameters for?
Before we get to the meaning of parameter, let's start by talking about methods.

A method is a collection of instructions, also known as a block of code, which is designed to perform tasks and operations. In order for us to make the method execute these instructions, it is necessary to pass the necessary information for the method's action to take place. This necessary information is captured through parameters.

In technology, we can say that parameters are the characteristics that the user adds. By defining a parameter we also specify the way in which it can be used.

It is worth paying attention to the difference between parameters and arguments, where parameter is the variable that will receive a value in a method while an argument is the value.

Some points to differentiate parameters and arguments
Parameters

  • Are defined in the method declaration (signature);
  • They receive arguments;
  • A tip to avoid confusion is to think of the "P" for parameter is like the "P" in Placeholder, which is for a Potential value.

Arguments

  • They represent the current values/variables passed to the parameters of the function when it is called;
  • Each argument corresponds to one parameter (position);
  • Tip: Argument = current value.

What is the difference between formal parameters and actual parameters?
Still talking about parameters, we have these two types, which are formal parameters and actual parameters. The main difference between them is how they are executed where:

We can say that actual parameters are those values that we pass to the method when it is called.

Formal parameters, on the other hand, are the variables defined by the method that are given values when the method is called.

Reference
Oracle. (n.d.). Defining Methods (The JavaTM Tutorials > Learning the Java Language > Classes and Objects). Docs Oracle. Retrieved July 5, 2022, from Java documentation

Oldest comments (0)