Mindmap
methods and parameters of type object
Inhalt der Mindmap
methods and parameters of type object
Passing Information to a Method or a Constructor
- The declaration for a method or a constructor declares the number and the type of the arguments for that method or constructor
Parameters refers to the list of variables in a method declaration.
- Arguments are the actual values that are passed in when the method is invoked.
- You use varargs when you don't know how many of a particular type of argument will be passed to the method.
- This includes primitive data types, such as doubles, floats, and integers, as you saw in the computePayment method, and reference data types, such as objects and arrays.
- Arguments are the actual values that are passed in when the method is invoked.
When you declare a parameter to a method or a constructor, you provide a name for that parameter. This name is used within the method body to refer to the passed-in argument.
- Many developers use the terms "type parameter" and "type argument" interchangeably, but these terms are not the same.
- When coding, one provides type arguments in order to create a parameterized type.
- Many developers use the terms "type parameter" and "type argument" interchangeably, but these terms are not the same.
A parameter can have the same name as one of the class's fields
public class Circle { private int x, y, radius; public void setOrigin(int x, int y) {
public static void main(String[] args) { int x = 3; // invoke passMethod() with // x as argument passMethod(x); // print x to see if its // value has changed System.out.println("After invoking passMethod, x = " + x);
By convention, type parameter names are single, uppercase letters.
- Without this convention, it would be difficult to tell the difference between a type variable and an ordinary class or interface name.
Informationen
- Beschreibung
- Mindmap am methods and parameters of type object, erstellt von daniela rodriguez am 17/05/2019.
- Erstellt von
- daniela rodriguez
- Aufrufe
- 0
- Verlauf
-
- Erstellt von daniela rodriguez · 15 Mai 2019
- Kopiert von daniela rodriguez · 17 Mai 2019
- Bewertung