Index
Metodi
Declaring a Java Method
The syntax to declare a method is:
Tip
returnType
- It specifies what type of value a method returns For example if a method has anint
return type then it returns an integer value.methodName
- It is an identifier that is used to refer to the particular method in a programmodifier
- It defines access types whether the method is public, private, and so on. To learn more, visit Java Access Modifierparameter1/parameter2
- These are values passed to a method. We can pass any number of arguments to a method.static
- If we use thestatic
keyword, it can be accessed without creating objects.
- For example, the
sqrt()
method of standard Java Math class is static. Hence, we can directly callMath.sqrt()
without creating an instance ofMath
class.
oss
- If the method does not return a value, its returnType is
void
.- il
modifier
di metodo è tipicamente pubblico, ovvero visibile a tutti