+ 3
What is the difference between parameters and instances
2 ответов
+ 5
parameters is values hat you passed to function and that is in function declaration and instance is another name for the object, for example if you have set method:
class Test
{
private int n;
public void setNumber(int n)
{
this.n = n; /* this.n is instance of object for which you called this method and n is parameter of function */
}
}
+ 1
They are not comparable...
An object is an instance of a class.
As such
Test a = new Test(); // creates a new instance of the class Test
A method may has some parameters which will be shown in the method's signature.
void method(int b) {} // b is a parameter