+ 1

In Java, can you pass an object to a method within the constructor for that object?

I would like to utilize a static method which accepts an object in the constructor for that object, in order to set other variables in the same constructor. Is this possible?

3rd Feb 2017, 6:17 AM
Daniel
Daniel - avatar
1 Respuesta
+ 1
Yes you can. Just add a parameter type of your object and then just add the "this" keyword from your object as parameter.
3rd Feb 2017, 6:42 AM
Nikolai Russev
Nikolai Russev - avatar