I'm currently working on java legacy code and I encounter with a class that represent a formal parameter but I don't know why is that. I read about C++ Formal Parameters, but it confused me because in C++ it is the same as the argument (I'm in doubt about this affirmation) and in my legacy code it is a class, that has only a private int member that store a number (with their set & get methods) but honestly, I didn't find the why of that declaration.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Not disagreeing with Elliot Frisch at all, but I can say it more simply:
The variable
w
is a "formal parameter" in the following function definition:The value returned by
nextWidget(...)
is the "actual parameter" when you write the following function call:In Java and in C++ the formal parameter is specified in the signature of the method:
callIt
has a single formal parameter that is aString
. At run-time we talk about actual parameters (or arguments), the :"Hello, World"
String
is an actual parameter,String a
is a formal parameter.From the Wikipedia entry for parameter:
and:
Well, coming to Java or any language these definitions always hold true:
caller — the function is invoking the function call.
callee — the function that is invoked by the caller.
An argument term technically in programming refers to the data that is passed by caller to the callee.
And a parameter term technically refers to the type of data being passed more specifically to an identifier which identifies the type of data. So a parameter more or less refers to the identifier that identifies a particular type. Coming further, a formal parameter is the identifier used in the callee's method signature.
And an actual parameter is the identifier used by the caller when invoking the call.
Since you know that we can even pass the arguments (i.e. data) in the call to the callee directly, actual parameters are not compulsory and hence directly data can be passed whereas formal parameters are always compulsory.