+ 3

What is the difference between parameters and instances

1st Feb 2018, 4:08 PM
The Programmer The Programmer
The Programmer The Programmer - avatar
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 */ } }
1st Feb 2018, 4:51 PM
Vukan
Vukan - avatar
+ 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
1st Feb 2018, 4:47 PM
Andreas K
Andreas K - avatar